简体   繁体   English

Dreamweaver HTML-列高

[英]Dreamweaver HTML - Column Heights

I'm having trouble making two columns expandable while retaining equal heights. 我无法在保持相等高度的同时使两列可扩展。 I have included snippets from my CSS file and HTML. 我已经包括了我的CSS文件和HTML中的代码段。 I have browsed through page after page of similar issues yet nothing seems to work! 我浏览了类似问题的页面,但似乎无济于事! I know I'm probably forgetting something simple. 我知道我可能忘记了一些简单的事情。 Below is how my HTML is setup as well as some CSS. 以下是我的HTML以及一些CSS的设置方式。 Above these tags are the header and nav but I did not think that code was relevant so I didn't post it. 在这些标签上方是header和nav,但我认为代码没有相关性,因此没有发布。

<div id="Main">

    <div id="RightColumn-Template">
    <p>Hey</p>
    </div>

    <div id="LeftColumn-Template">
    <br><br><br>
    </div>
    </div>

#container {
width: 1000px;
margin-left:auto;
margin-right:auto;
overflow-y: auto;
}
header {
height: 136px;
width:1000px;
line-height:0px;
padding:0px;
margin:0px;
}
nav {
height: 30px;
width: 1000px;
background-color:#219971;
line-height:0px;
padding:0px;
margin:0px;
}
#Main {
width:1000px;
height:100%;
overflow:auto;
clear:both;
}
#RightColumn-Template {
background-image:url(../KeddcoImages/PipeBG.jpg);
background-repeat:no-repeat;
background-color:#A4A7AC;
padding:25px;
width: 200px;
height:100%;
float: left;
}
#LeftColumn-Template {
background-color:#FFF;
background-repeat:repeat-y;
padding:25px;
width:700px;
height:100%;
float:right;
}

There are few ways you can use to create equal height columns. 可以使用几种方法来创建等高的列。

First one is Flex Method using display:flex . 第一个是使用display:flex Flex Method

 div#Main{display:flex;flex-direction: row;} div#Main >div{border:1px solid gray;width: 50%; padding: 10px;} 
  <div id="Main"> <div id="RightColumn-Template"> <p>Hey</p> <p>Hey</p><p>Hey</p><p>Hey</p> </div> <div id="LeftColumn-Template"> <p>Hey</p> </div> </div> 

second method is using display:table for parent element and display:table-cell for child element. 第二种方法是将display:table用于父元素,将display:table-cell用于子元素。

 div#Main{display:table;} div#Main >div{border:1px solid gray;width: 50%; padding: 10px;display:table-cell;} 
  <div id="Main"> <div id="RightColumn-Template"> <p>Hey</p> <p>Hey</p><p>Hey</p><p>Hey</p> </div> <div id="LeftColumn-Template"> <p>Hey</p> </div> </div> 

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM