[英]different height grid system css
I'm new to html&css, I'm trying to set the following grid system: current state 我是html&css的新手,我试图设置以下网格系统: 当前状态
look like this: desired solution 看起来像这样: 所需的解决方案
My html code consists of 2 main divs (for each 'row'), each one contains 2 divs (logo + notes, nav + content) I've used display: inline-block in each div, but still can't figure out how to place the blue box directly under the yellow one? 我的html代码由2个主要div组成(每个“行”),每个div包含2个div(徽标+注释,导航+内容),我使用过display:inline-block in each div,但仍然无法弄清楚如何将蓝色框直接放在黄色框下面? I prefer a solution without jquery plugins, the simplest solution there is thanks
我更喜欢没有jquery插件的解决方案,最简单的解决方案是谢谢
Code: 码:
.header { display: inline-block; width: 100%; } .logo { display: inline-block; width: 30%; height: 100px; background-color: red; } .notes { display: inline-block; width: 69%; height: 50px; background-color: yellow; } .nav { display: inline-block; width: 30%; height: 50px; background-color: green; } .content { display: inline-block; width: 69%; height: 50px; background-color: blue; }
<div class="header"> <div class="logo"> Logo </div> <div class="notes"> Notes </div> </div> <div class="main"> <div class="nav"> Nav </div> <div class="content"> Content </div> </div>
I know this isn't a great way of doing it but this method works. 我知道这不是一个好方法,但是这种方法有效。 Here are the change, which I have made for you
.content
: 这是我为您所做的更改
.content
:
top: 50px;
left: calc(30% + 7px);
width: calc(69% - 10px);
Here is the final code: 这是最终代码:
.header { display: inline-block; width: 100%; } .logo { display: inline-block; width: 30%; height: 100px; background-color: red; } .notes { display: inline-block; width: 69%; height: 50px; background-color: yellow; } .nav { display: inline-block; width: 30%; height: 50px; background-color: green; } .content { display: inline-block; width: calc(69% - 10px); height: 50px; background-color: blue; position: fixed; top: 50px; left: calc(30% + 7px); }
<div class="header"> <div class="logo"> Logo </div> <div class="notes"> Notes </div> </div> <div class="main"> <div class="nav"> Nav </div> <div class="content"> Content </div> </div>
I would re-arrange the markup and make 2 columns. 我将重新排列标记并制作2列。
.header { display: inline-block; width: 30%; float: left; } .logo { height: 100px; background-color: red; } .notes { height: 50px; background-color: yellow; } .main { margin-left: 30%; } .nav { height: 50px; background-color: green; } .content { height: 50px; background-color: blue; }
<div class="header"> <div class="logo"> Logo </div> <div class="nav"> Nav </div> </div> <div class="main"> <div class="notes"> Notes </div> <div class="content"> Content </div> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.