基本上,我想在页面顶部有一排三角形.他们应该面朝下.我已经在CSS中创建了三角形,但由于某种原因,他们想要在彼此之上上下,而不是像我一样需要它们.
有没有CSS经验的人可以看看吗?谢谢.
HTML:
<div class="triangle-container">
<div class="arrow-down">
</div>
<div class="arrow-down">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
/* BODY */
body
{
background-color: #eee;
height: 100%;
width: 100%;
z-index: 1;
padding: none;
border: none;
margin: none;
}
/* Triangles! */
.triangle-container
{
display: inline;
height: auto;
width: 100%;
position: absolute;
top: 0;
left: 0;
text-align: center;
}
.arrow-down
{
margin-left:auto;
margin-right:auto;
width:0;
height:0;
border-left:50px solid transparent;
border-right:50px solid transparent;
border-top:50px solid #FF6A00;
}
Run Code Online (Sandbox Code Playgroud)
您必须应用于display:inline要内联显示的元素,而不是其容器.
在你的情况下,它应该是inline-block,因为它应该是inline行为作为block元素的元素.在这里阅读更多.
把display:inline-block对.arrow-down和删除.triangle-container:
.triangle-container
{
display: inline; /* Remove this line */
height: auto;
width: 100%;
position: absolute;
top: 0;
left: 0;
text-align: center;
}
.arrow-down
{
display: inline-block; /* Add this line */
margin-left:auto;
margin-right:auto;
width:0;
height:0;
border-left:50px solid transparent;
border-right:50px solid transparent;
border-top:50px solid #FF6A00;
}
Run Code Online (Sandbox Code Playgroud)
现场演示:jsFiddle
| 归档时间: |
|
| 查看次数: |
1361 次 |
| 最近记录: |