網(wǎng)站首頁 編程語言 正文
純css控制文字顯示隱藏
用到css 偽類 :checked
:checked 選擇器匹配每個(gè)已被選中的 input 元素(只用于單選按鈕和復(fù)選框)。
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;
}/*用于調(diào)整單選框的屬性以及位置*/
.label2{
position: absolute;
bottom: 0;
left: 0;
height: 20px;
line-height: 20px;
color: rgb(96,115,232);
cursor: pointer;
display: none;
}/*用于調(diào)整單選框的屬性以及位置*/
#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機(jī)制相關(guān)流程
- 下一篇:Samba安裝與配置流程
相關(guān)推薦
- 2022-04-17 新版本VS Code 終端設(shè)置為git bash
- 2022-05-23 Python學(xué)習(xí)之sys模塊使用教程詳解_python
- 2022-10-03 C++利用Opencv實(shí)現(xiàn)多個(gè)圓形檢測(cè)_C 語言
- 2022-07-27 python中format的用法實(shí)例詳解_python
- 2022-07-23 python實(shí)現(xiàn)雙向鏈表原理_python
- 2022-08-27 python?中defaultdict()對(duì)字典進(jìn)行初始化的用法介紹_python
- 2023-01-02 正確在Flutter中添加webview實(shí)現(xiàn)詳解_Android
- 2022-12-13 python3.x?zip用法小結(jié)_python
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支