Css 嵌套div时,在div底部放置三角形等

Css 嵌套div时,在div底部放置三角形等,css,Css,我试图在下面的代码块上使用,但我不确定是因为嵌套的div还是section标记,我无法让它工作 这就是我试图实现的目标:(这是我模拟的PNG) 但是,我现在看到了这个(jsfiddle链接): <div class="entry-content"> <section class="vc_section_wrapper has_bg_color"> <div class="bg-layer" style="background-color:

我试图在下面的代码块上使用,但我不确定是因为嵌套的div还是section标记,我无法让它工作

这就是我试图实现的目标:(这是我模拟的PNG)

但是,我现在看到了这个(jsfiddle链接):

<div class="entry-content">
    <section class="vc_section_wrapper has_bg_color">
        <div class="bg-layer" style="background-color: rgb(114, 114, 255); height: 347px;" data-inertia="0.1">
        </div>
        <div class="wpb_row row-fluid">
            <div class="span12 wpb_column column_container">
                <div class="wpb_wrapper">
                    <div class="wpb_text_column wpb_content_element ">
                        <div class="wpb_wrapper">
                            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam nec odio ac lectus mattis pellentesque vel eu erat. Aliquam a libero non quam molestie interdum in ut urna.</p>
                        </div> 
                    </div> 
                </div> 
            </div> 
        </div>
    </section>
    <section class="vc_section_wrapper has_bg_color">
        <div class="bg-layer" style="background-color: rgb(158, 27, 52); height: 227px;" data-inertia="0.1">
        </div>
        <div class="wpb_row row-fluid">
            <div class="span12 wpb_column column_container">
                <div class="wpb_wrapper">
                    <div class="wpb_text_column wpb_content_element ">
                        <div class="wpb_wrapper">
                            <p>Interdum et malesuada fames ac ante ipsum primis in faucibus. In varius posuere elit, nec ultrices ligula posuere in. Vestibulum ut sollicitudin eros, et vestibulum magna. .</p>
                        </div> 
                    </div> 
                </div> 
            </div> 
        </div>
    </section>
</div>
.vc_section_wrapper .bg-layer {
    position: absolute; 
    width: 100%; 
    height: 100%; 
    left: 0;
}

.vc_section_wrapper.has_bg_color > .wpb_row, .vc_section_wrapper.has_bg_img > .wpb_row { 
    padding-top: 40px;  
    position: relative;
}

.triangle-down{
    width: 2.5%;
    height: 0;
    padding-left:2.5%;
    padding-top: 2.5%;
    overflow: hidden;
    position: absolute;
    left:0;right:0;
    margin:auto;
    top: 100px;
    z-index:1;
}
.triangle-down:before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    margin-left:-50px;
    margin-top:-50px;

    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-top: 50px solid pink;
}

HTML:

<div class="entry-content">
    <section class="vc_section_wrapper has_bg_color">
        <div class="bg-layer" style="background-color: rgb(114, 114, 255); height: 347px;" data-inertia="0.1">
        </div>
        <div class="wpb_row row-fluid">
            <div class="span12 wpb_column column_container">
                <div class="wpb_wrapper">
                    <div class="wpb_text_column wpb_content_element ">
                        <div class="wpb_wrapper">
                            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam nec odio ac lectus mattis pellentesque vel eu erat. Aliquam a libero non quam molestie interdum in ut urna.</p>
                        </div> 
                    </div> 
                </div> 
            </div> 
        </div>
    </section>
    <section class="vc_section_wrapper has_bg_color">
        <div class="bg-layer" style="background-color: rgb(158, 27, 52); height: 227px;" data-inertia="0.1">
        </div>
        <div class="wpb_row row-fluid">
            <div class="span12 wpb_column column_container">
                <div class="wpb_wrapper">
                    <div class="wpb_text_column wpb_content_element ">
                        <div class="wpb_wrapper">
                            <p>Interdum et malesuada fames ac ante ipsum primis in faucibus. In varius posuere elit, nec ultrices ligula posuere in. Vestibulum ut sollicitudin eros, et vestibulum magna. .</p>
                        </div> 
                    </div> 
                </div> 
            </div> 
        </div>
    </section>
</div>
.vc_section_wrapper .bg-layer {
    position: absolute; 
    width: 100%; 
    height: 100%; 
    left: 0;
}

.vc_section_wrapper.has_bg_color > .wpb_row, .vc_section_wrapper.has_bg_img > .wpb_row { 
    padding-top: 40px;  
    position: relative;
}

.triangle-down{
    width: 2.5%;
    height: 0;
    padding-left:2.5%;
    padding-top: 2.5%;
    overflow: hidden;
    position: absolute;
    left:0;right:0;
    margin:auto;
    top: 100px;
    z-index:1;
}
.triangle-down:before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    margin-left:-50px;
    margin-top:-50px;

    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-top: 50px solid pink;
}
我不知道这是否仅仅是一个CSS更改,我怀疑我是否将这行代码放在了正确的位置:

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

您可以在此处替换它:

<div class="bg-layer" style="background-color: rgb(158, 27, 52); height: 227px;" data-inertia="0.1">
  <div class="triangle-down"></div>
</div>

然后在课堂上将
top:100%
改写为
top:0
,然后将
三角形向下


您可以在此处更换:

<div class="bg-layer" style="background-color: rgb(158, 27, 52); height: 227px;" data-inertia="0.1">
  <div class="triangle-down"></div>
</div>

然后在课堂上将
top:100%
改写为
top:0
,然后将
三角形向下


您可以在此处更换:

<div class="bg-layer" style="background-color: rgb(158, 27, 52); height: 227px;" data-inertia="0.1">
  <div class="triangle-down"></div>
</div>

然后在课堂上将
top:100%
改写为
top:0
,然后将
三角形向下


您可以在此处更换:

<div class="bg-layer" style="background-color: rgb(158, 27, 52); height: 227px;" data-inertia="0.1">
  <div class="triangle-down"></div>
</div>

然后在课堂上将
top:100%
改写为
top:0
,然后将
三角形向下


我会稍微改变一下

包含三角形的div

位置<代码>位置:相对在上面,然后你可以使用
top:100%以使三角形正好位于底部

css:


小提琴手:

我会在这方面做一些不同的事情

包含三角形的div

位置<代码>位置:相对在上面,然后你可以使用
top:100%以使三角形正好位于底部

css:


小提琴手:

我会在这方面做一些不同的事情

包含三角形的div

位置<代码>位置:相对在上面,然后你可以使用
top:100%以使三角形正好位于底部

css:


小提琴手:

我会在这方面做一些不同的事情

包含三角形的div

位置<代码>位置:相对在上面,然后你可以使用
top:100%以使三角形正好位于底部

css:


小提琴:我认为其他答案是正确的。但我认为这是一个很好的机会,可以在课后使用css来清理html并简化事情。例如

html:


我认为其他答案是正确的。但我认为这是一个很好的机会,可以在课后使用css来清理html并简化事情。例如

html:


我认为其他答案是正确的。但我认为这是一个很好的机会,可以在课后使用css来清理html并简化事情。例如

html:


我认为其他答案是正确的。但我认为这是一个很好的机会,可以在课后使用css来清理html并简化事情。例如

html:


谢谢@gial的回答,当我把它添加到我的代码中时,它立即起作用了。谢谢@gial的回答,当我把它添加到我的代码中时,它立即起作用了。谢谢@gial的回答,当我把它添加到我的代码中时,它立即起作用了。