简体   繁体   English

我如何添加另一个div来覆盖.left,.mid和.right右侧的所有空间?

[英]how can i add another div which will cover all the space present in the right side of .left, .mid and .right?

Hello there i want to add one more div on the right side of 3 divs ie left, right and mid, i am new to CSS, also if you could then please also explain how to position complex div designing, or please share a link to resource which elaborates this concept easily Here is my complete source code.. Here is the output 您好,我想在3个div的右侧添加一个div,即left,right和mid,我是CSS新手,如果可以的话,还请解释如何定位复杂的div设计,或者共享一个链接到轻松阐述这个概念的资源这是我完整的源代码。 这是输出

<html>
    <head>
        <title>Template</title>
        <style>
            body {
                background-color: black;
            }

            .top, .left, .right, .mid, .bottom {
                margin: 5px;
                background-color: plum;
                padding: 5px;
            }

            .left, .right, .mid {
                width: 30%;
            }
        </style>
    </head>

    <body>
        <div class="top">
            <p>Top</p>
        </div>

        <div class="left">
            <p>Left</p>
        </div>

        <div class="mid">
            <p>Mid</p>
        </div>

        <div class="right">
            <p>Right</p>
        </div>

        <div class="bottom">
            <p>Bottom</p>
        </div>
    </body>
</html>

You can create a flex row with 2 flex children and put the left/mid/right elements in the left flex child set to the flex-basis you want those to occupy, then set the other flex child to flex-grow: 1 . 您可以创建一个带有2个flex子元素的flex行,并将左flex子元素中的left / mid / right元素设置为您希望它们占据的flex-basis ,然后将另一个flex子元素设置为flex-grow: 1 I'm using the shorthand properties in this code. 我在这段代码中使用速记属性。

 body { background-color: black; } .top, .left, .right, .mid, .bottom, .panel2 { margin: 5px; background-color: plum; padding: 5px; } .flex { display: flex; } .panel1 { flex: 0 0 30%; } .panel2 { flex: 1 0 0; background: blue; } 
 <div class="top"> <p>Top</p> </div> <div class="flex"> <div class="panel panel1"> <div class="left"> <p>Left</p> </div> <div class="mid"> <p>Mid</p> </div> <div class="right"> <p>Right</p> </div> </div> <div class="panel panel2"> foo </div> </div> <div class="bottom"> <p>Bottom</p> </div> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 怎样才能让照片中的div填满左边所有的空白? 它只完全向右填充 - How can make the div in the photo fill all the white space on the left side? It only fills fully to the right CSS-如何将div并排放置,左右之间没有空格 - CSS - How to place div side by side with no space at left and right 我怎么放两个 <div> 并排,左 <div> 占用权利未占用的空间的100% <div> ? - How do I put two <div>s side-by-side, with the left <div> taking up 100% of the space not taken up by the right <div>? 为什么 output 右侧有一个空间?如何使用引导程序 4 填充空间? - why there is a space left at right side of output?How can i fill the space using bootstrap 4? 如何使用 Javascript 将 div 附加到另一个 div 的右侧或左侧? - How do I attach a div to the right or left side of another div using Javascript? 如何使用jqueryui仅在左侧调整div的大小,并且仅在左侧调整相邻的div的大小? - How can I resize a left side div on its right side only, and it's neighboring right side div, on its left side only, using jqueryui? 如何从 blospot 主题(网络)中删除左侧和右侧的空白区域? - How can i remove the blank white space of left and right side from the blospot theme (Cyber)? 如何向左和向右添加渐变? - How can I add gradient to left and to right? 我如何将一个div分为两个,用于在左侧显示文本,在右侧显示图像 - how i can divide one div on two, for display text on left, and image on right side 如何将内容对齐到div的所有四个角(右上,左上,右下,左下),并在每个角上都有边距? - How can i align content to all four corners of a div (top right, top left, bottom right, bottom left) and have margin on each?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM