Css-如何在文本框外添加图像(在左侧但触摸框)
在我的网站上,我想在每个白色文本框旁边添加一个小“+”图标(我制作了一个我试图实现的模型:),但我不知道怎么做。 你有什么建议? 非常感谢, 以下是html代码:Css-如何在文本框外添加图像(在左侧但触摸框),css,textbox,alignment,Css,Textbox,Alignment,在我的网站上,我想在每个白色文本框旁边添加一个小“+”图标(我制作了一个我试图实现的模型:),但我不知道怎么做。 你有什么建议? 非常感谢, 以下是html代码: <div class="presentation-plusbox"> <p>Expertise dans l'industrie</p> <p>blblablabla</p> <p>blabla</p> </div> 将+框定义为中的di
<div class="presentation-plusbox">
<p>Expertise dans l'industrie</p>
<p>blblablabla</p>
<p>blabla</p>
</div>
将+框定义为
中的div。presentation plusbox
同时将位置:相对添加到。演示文稿plusbox
然后将以下css应用于加号框
.plusBox {
position: absolute;
top: 20px;
left: -50px;
}
当然,您需要调整顶部
和左侧
,使其刚好正确。您可以使用:before
-
请注意-:在IE7及以下版本中不支持之前
我还没有尝试过,但应该可以
p { position: relative; }
p:after {
height: 20px;
width: 20px;
background-image: url('image.url.goes.here.jpg');
position: absolute;
top: 5px;
left: -20px;
}
我想你希望图标可以点击?我想我会选择这个解决方案,但是非常感谢你的建议!我想我会选择这个解决方案,但是非常感谢你的建议!看起来不错,尽管+不会出现在旧的浏览器中(如您所注意的),也不会呈现为实际的DOM元素,因此它不能是交互式的。
div:before {
content: "+";
height: 30px;
width: 30px;
text-align: center;
line-height: 30px;
background: orange;
color: #fff;
display: block;
left: -30px;
position: absolute;
}
p { position: relative; }
p:after {
height: 20px;
width: 20px;
background-image: url('image.url.goes.here.jpg');
position: absolute;
top: 5px;
left: -20px;
}