網站首頁 編程語言 正文
純css控制文字顯示隱藏
用到css 偽類 :checked
:checked 選擇器匹配每個已被選中的 input 元素(只用于單選按鈕和復選框)。
html
<div class="box">
<input type="radio" name="clickInput" value="0" id="Input1" hidden>
<label class="label1" for="Input1">更多</label>
<input type="radio" name="clickInput" value="1" id="Input2" hidden>
<label class="label2" for="Input2">收起</label>
<div class="text">文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字</div>
</div>
css
.box{
position: relative;
margin:auto;
width: 180px;
overflow: hidden;
padding-bottom: 20px;
}
.text{
height: 40px;
color: #555555;
word-break:break-word ;
word-wrap: break-word;
line-height: 20px;
overflow: hidden;
}
.label1{
position: absolute;
bottom: 0;
left: 0px;
height: 20px;
line-height: 20px;
color: rgb(96,115,232);
cursor: pointer;
}/*用于調整單選框的屬性以及位置*/
.label2{
position: absolute;
bottom: 0;
left: 0;
height: 20px;
line-height: 20px;
color: rgb(96,115,232);
cursor: pointer;
display: none;
}/*用于調整單選框的屬性以及位置*/
#Input1:checked~div{height: auto}/*展開高度*/
#Input1:checked~.label1{
display: none;}/*隱藏更多*/
#Input1:checked~.label2{
display: block;}/*顯示收起*/
#Input2:checked~div{
height: 40px;}/*還原高度*/
#Input2:checked~.label2{
display: none;}/*隱藏收起*/
效果 更多和收起按鈕切換
就醬了~~
原文鏈接:https://blog.csdn.net/qq_34724739/article/details/116270939
- 上一篇:Handler機制相關流程
- 下一篇:Samba安裝與配置流程
相關推薦
- 2022-07-21 微信小程序使用vant weapp報錯
- 2022-07-04 pandas讀取中文xlsx文件出現的問題_python
- 2023-01-19 GO語言的map類型實例詳解_Golang
- 2023-03-22 幾分鐘教你掌握Redis簡單動態字符串SDS_Redis
- 2022-12-15 詳解Golang如何比較兩個slice是否相等_Golang
- 2022-02-14 el-form的label和表單自適應填滿一行且靠左對齊
- 2023-05-12 Oracle中實現刪除重復數據只保留一條_oracle
- 2022-10-17 docker?compose運行微服務項目的方法_docker
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支