gpt4 book ai didi

javascript - CSS 中的不平衡和不完全响应的网格

转载 作者:太空宇宙 更新时间:2023-11-04 06:48:25 27 4
gpt4 key购买 nike

我正在尝试将三个网格放入一个 div 中并使其响应。但是无法正确管理它。网格有一些平衡问题。第一个网格有一个图像。第二个(中心)网格有一个文本。最后一个(第三个)网格将有一个按钮。

当我尝试缩小浏览器或通过手机连接时。网格没有得到平衡并且没有响应。我在这里做错了什么?我真的很感激任何帮助!谢谢。

html, body {
background-color: #fff;
color: #636b6f;
font-family: "Helvetica Neue", 'lato', sans-serif;
font-weight: 300;
margin: 0;
}

.row {
width: 50%;
margin: 0 auto;
}


.banner-back-ground {
width: 100%;
background-color: #f5f6fa;
}

h1 {
color: #4CAF50;
padding-top: 15px;
padding-bottom: 15px;
margin: 0;
}

.nav-back-ground {
background-color: #333;
margin-bottom: 50px;
}

ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}

li {
float: left;
}

li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

li a:hover {
background-color: #111;
}

.active {
background-color: #4CAF50;
}

img {
height: 130px;
width: 130px;
border-radius: 3px;
}

.all-content-wrapper {
border: solid 1px #333;
border-radius: 3px;
box-sizing: border-box;
padding: 10px;
}

/* SECTIONS */
.all-content-wrapper {
clear: both;
margin: 0px;
}

/* COLUMN SETUP */
.col {
display: block;
float:left;
}
.col:first-child { margin-left: 0; }

/* GROUPING */
.group:before,
.group:after { content:""; display:table; }
.group:after { clear:both;}
.group { zoom:1; /* For IE 6/7 */ }

/* GRID OF THREE */
.span_3_of_3 { width: 20%; margin: auto; }
.span_2_of_3 { width: 60%; margin: auto; }
.span_1_of_3 { width: 20%; }

/* GO FULL WIDTH BELOW 480 PIXELS */
@media only screen and (max-width: 480px) {
.col { margin: 1% 0 1% 0%; }
.span_3_of_3, .span_2_of_3, .span_1_of_3 { width: 100%; }
}

.content-text ul {
background-color: white;
list-style-type: none;
margin: 0;
padding: 0;
}

.content-text li {
float: left;
}
 <div class="banner-back-ground">
<div class="row">
<h1>BEN</h1>
</div>
</div>

<div class="nav-back-ground">
<div class="row">
<ul>
<li><a class="active" href="#home">東北</a></li>
<li><a href="#news">関西</a></li>
<li><a href="#contact">北海道</a></li>
<li><a href="#contact">関東</a></li>
<li style="float:right"><a href="#about"><i class="fa fa-search"></i> 検査</a></li>
</ul>
</div>
</div>

<section>
<div class="row">
<div class="all-content-wrapper group">
<div class="col span_1_of_3">
<img src="https://dummyimage.com/130x130/000/fff.jpg" alt="">
</div>
<div class="col span_2_of_3">
<span class="content-text">
<ul>
<li>asldkas;ldka;sldka;sdlka;sdlka;sdja;sdjasdjlakjsdlakjsdlakjddasdasdsa</li>
<li>sdlalsdka;sdkad</li>
<li>;alskda;slkda;lsdkasd</li>
<li>alksd:a;sklda;ksda;sdk;askd</li>
</ul>
</span>
</div>
<div class="col span_3_of_3">
Here Button
</div>
</div>
</div>
</section>

正如您在代码片段导航栏和 div 内部看到的那样,响应不是很好......

最佳答案

html, body {
background-color: #fff;
color: #636b6f;
font-family: "Helvetica Neue", 'lato', sans-serif;
font-weight: 300;
margin: 0;
}

.row {
width: 50%;
margin: 0 auto;
}


.banner-back-ground {
width: 100%;
background-color: #f5f6fa;
}

h1 {
color: #4CAF50;
padding-top: 15px;
padding-bottom: 15px;
margin: 0;
}

.nav-back-ground {
background-color: #333;
margin-bottom: 50px;
}

ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}

li {
float: left;
}

li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

li a:hover {
background-color: #111;
}

.active {
background-color: #4CAF50;
}

img {
height: 130px;
width: 130px;
border-radius: 3px;
}

.all-content-wrapper {
border: solid 1px #333;
border-radius: 3px;
box-sizing: border-box;
padding: 10px;
}

/* SECTIONS */
.all-content-wrapper {
clear: both;
margin: 0px;
/* flex layout with wrap for ease of achieving responsive design */
display:flex;
flex-wrap:wrap;
}

/* COLUMN SETUP */
.col {
display: block;
/* don't need float with flex - float:left; */
/* specify grow, shrink and basis width */
flex:0 0 auto;
}
.col:first-child { margin-left: 0; }

/* GROUPING */
.group:before,
.group:after { content:""; display:table; }
.group:after { clear:both;}
.group { zoom:1; /* For IE 6/7 */ }

/* GRID OF THREE */
.span_3_of_3 { width: 20%; margin: auto; }
.span_2_of_3 { width: 60%; margin: auto; }
.span_1_of_3 { width: 20%; }

/* GO FULL WIDTH BELOW 480 PIXELS */
@media only screen and (max-width: 480px) {
.col { margin: 1% 0 1% 0%; }
.span_3_of_3, .span_2_of_3, .span_1_of_3 { width: 100%; }
}

.content-text ul {
background-color: white;
list-style-type: none;
margin: 0;
padding: 0;
}

.content-text li {
float: left;
}
 <div class="banner-back-ground">
<div class="row">
<h1>BEN</h1>
</div>
</div>

<div class="nav-back-ground">
<div class="row">
<ul>
<li><a class="active" href="#home">東北</a></li>
<li><a href="#news">関西</a></li>
<li><a href="#contact">北海道</a></li>
<li><a href="#contact">関東</a></li>
<li style="float:right"><a href="#about"><i class="fa fa-search"></i> 検査</a></li>
</ul>
</div>
</div>

<section>
<div class="row">
<div class="all-content-wrapper group">
<div class="col span_1_of_3">
<img src="https://dummyimage.com/130x130/000/fff.jpg" alt="">
</div>
<div class="col span_2_of_3">
<span class="content-text">
<ul>
<li>asldkas;ldka;sldka;sdlka;sdlka;sdja;sdjasdjlakjsdlakjsdlakjddasdasdsa</li>
<li>sdlalsdka;sdkad</li>
<li>;alskda;slkda;lsdkasd</li>
<li>alksd:a;sklda;ksda;sdk;askd</li>
</ul>
</span>
</div>
<div class="col span_3_of_3">
Here Button
</div>
</div>
</div>
</section>

关于javascript - CSS 中的不平衡和不完全响应的网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53085253/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com