html - 如何让 CSS 三 Angular 形显示在一行而不是垂直

标签 html css

基本上,我想要在页面顶部有一排三 Angular 形。他们应该面朝下。我已经在 CSS 中制作了三 Angular 形,但出于某种原因,它们想要在彼此之上上下移动,而不是排成一排,就像我也需要它们一样。

请有经验的CSS friend 看看?谢谢。

HTML:

<div class="triangle-container">

    <div class="arrow-down">
    </div>

    <div class="arrow-down">
    </div>

</div>

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;
}

jsFiddle demo

最佳答案

您必须将 display:inline 应用于您希望内联显示的那些元素,而不是它们的容器。

在您的情况下,它应该是 inline-block,因为它应该是 inline 元素,其行为与 block 元素相同。阅读更多 here .


.arrow-down 放置 display:inline-block 并将其从 .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;
}

现场演示:jsFiddle

关于html - 如何让 CSS 三 Angular 形显示在一行而不是垂直,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12663190/

相关文章:

html - CSS 文本向右对齐但在换行符处向左对齐

javascript - 在 React 中向图像添加不透明覆盖层

html - 悬停时的 css 适用于前 3 个,然后不适用。 WordPress的

html - 在导航链接之间创建管道的问题

javascript - Jssor Slider 移动兼容性问题

css - 如何将后缀为 ‘.scss’的文件导入到Vue元素的子组件中?

Javascript 和 CSS 导致文本框消失,我希望它保留

javascript - 如何以及在哪里访问 gatsby 中的 html 正文

html - 如何阻止div重叠到图像?

检查元素无法识别 CSS 文件 - 谜团