標籤:
根據html代碼的不同來分成兩大類方法,如下
html代碼:
<h1 class="replace-indent">hello see</h1>
第一種方法:text-indent
.replace-indent{
height:200px;
width:200px;
background:url();
text-indent:-9999px;
}
第二種方法:
.replace-indent{
height:200px;
width:200px;
background:url();
text-indent:100%;
white-space:nowrap;
overflow:hidden;
}
第三種方法:
.replace-indent{
height:0px;
width:200px;
background:url();
padding:200px 0 0 0;
overflow:hidden;
}
第四種方法:before
.replace-indent{
width:image‘s width;
height:image‘s height;
overflow:hidden;
}
.replace-indent : before{
content:url();
}
html代碼:
<h1 class="replace-indent"><span>hello see</span></h1>
第一種方法:
.replace-indent{
height:200px;
width:200px;
background:url();
}
span{
display:none;
}
第二種方法:
.replace-indent{
height:200px;
width:200px;
background:url();
}
span{
width:0;
height:0;
display:block;
overflow:hidden;
}
第三種方法:
.replace-indent{
height:200px;
width:200px;
background:url();
}
span{
clip-path:polygon(0px 0px,0px 0px,0px 0px,0px 0px,0px 0px);
-webkit-clip-path:polygon(0px 0px,0px 0px,0px 0px,0px 0px,0px 0px);
}
css用背景圖來替換文字來達到隱藏文字的目的