【问题标题】:How to use CSS Grid in Genesis Column Classes?如何在创世纪列类中使用 CSS 网格?
【发布时间】:2018-11-18 13:03:30
【问题描述】:
如何在创世列类中使用 css 网格?我尝试了下面的代码,但列高不相等。
.one-half.first {
border: 1px solid #00569d;
padding: 10px;
display: table-cell;
}
.one-half {
width: 50%;
}
.one-half {
float: left;
}
.col-container {
display: table;
width: 100%;
}
@media only screen and (max-width: 600px) {
.one-half {
display: block;
width: 50%;
}
}
<div class="col-container">
<div class="one-half first">
<h3 style="text-align: center;">Important Dates</h3>
<ul style="list-style-type: square;">
<li><strong>Starting Date:</strong> 09-11-2018</li>
<li><strong>Last Date:</strong> 30-11-2018</li>
</ul>
</div>
<div class="one-half">
<h3 style="text-align: center;">Application Fee</h3>
<ul style="list-style-type: square;">
<li><strong>Rs.50/- :</strong> For All Candidates</li>
</ul>
</div>
</div>
以上代码的最终结果
【问题讨论】:
标签:
html
css
css-grid
genesis
【解决方案1】:
对于父容器,即col-container,将grid-template-columns 分别设置为 50%。
.col-container {
display: grid;
grid-template-columns: 50% 50%;
}
.one-half {
border: 1px solid #00569d;
padding: 10px;
display: table-cell;
}
<div class="col-container">
<div class="one-half first">
<h3 style="text-align: center;">Important Dates</h3>
<ul style="list-style-type: square;">
<li><strong>Starting Date:</strong> 09-11-2018</li>
<li><strong>Last Date:</strong> 30-11-2018</li>
</ul>
</div>
<div class="one-half">
<h3 style="text-align: center;">Application Fee</h3>
<ul style="list-style-type: square;">
<li><strong>Rs.50/- :</strong> For All Candidates</li>
</ul>
</div>
</div>
【解决方案2】:
.col-container {
width: 100%;
display: table;
}
h3 {
background: blue;
color: #fff;
}
.one-half {
width: 50%;
display: table-cell;
border: 1px solid #00569d;
padding: 10px;
}
<div class="col-container">
<div class="one-half first">
<h3 style="text-align: center;">Important Dates</h3>
<ul style="list-style-type: square;">
<li><strong>Starting Date:</strong> 09-11-2018</li>
<li><strong>Last Date:</strong> 30-11-2018</li>
</ul>
</div>
<div class="one-half">
<h3 style="text-align: center;">Application Fee</h3>
<ul style="list-style-type: square;">
<li><strong>Rs.50/- :</strong> For All Candidates</li>
</ul>
</div>
</div>
我必须在 CodePen 上添加。你能遵循 CodePen 的结构吗?
CodePen Demo