如何解决将CSS3伪:在形状之前与列表图像对齐
| 我正在尝试将CSS形状与列表图标对齐。 现在看起来像这样: 但是它应该看起来像: 我尝试使用position:absolute;亲戚和保证金,仍然一无所有。现场测试: http://jsfiddle.net/fzSrL/ CSS:.services-info ul {}
.services-info ul li {
background: #fff;
margin: 40px 0;
padding: 10px;
height: 115px;
width: 263px;
}
.services-info ul li:before {
content: \"\";
width: 0;
height: 0;
border-top: 50px solid transparent;
border-right: 100px solid red;
border-bottom: 50px solid transparent;
}
.services-info ul li:nth-of-type(1) {
list-style-image: url(../images/fb-icon.png);
}
.services-info ul li:nth-of-type(2) {
list-style-image: url(../images/twitter-icon.png);
}
.services-info ul li:nth-of-type(3) {
list-style-image: url(../images/yt-icon.png);
}
如何将它们对齐?还是将图像作为角落会是更好的选择?
解决方法
您需要在
li
上使用position: relative
,然后在\“ arrows \”(li:before
)上使用position: absolute
。
然后,您可以结合使用top
/left
和负margin-top
来精确定位箭头。
请参阅:http://jsfiddle.net/fzSrL/2/
此处介绍了此技术:http://css-tricks.com/absolute-positioning-inside-relative-positioning/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。