#html #css
#HTML #css — файл
Вопрос:
Я пытаюсь создать некоторый макет, но застрял с перекрывающимся div — ‘featured works’ — это все равно, что перейти под строку с 3 значками и, честно говоря, не могу найти решение для этого. Просто нужно поместить перекрывающийся div под разделом «три иконки». Также будет еще несколько в разделе, так что любые советы приветствуются.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
width: 100%;
max-width: 1200px;
margin: 0 auto;
}
/* columns */
.col-1 {
width: 8.33%;
}
... typical grid 1-12
/* offset */
.col-offset-1 {
margin-left: 8.33%;
}
... same as above
/* clearfix */
row::before,
row::after {
content: "";
display: table;
clear: both;
}
[class*="col-"] {
float: left;
min-height: 1px;
height: 150px;
padding: 10px;
}
/* === */
header nav {
background-color: #544B46;
overflow: hidden;
}
header nav ul {
float: right;
margin: 0;
padding: 0;
list-style-type: none;
}
header nav ul li {
display: inline-block;
}
header nav ul li a {
line-height: 50px;
display: block;
color: #fff;
padding: 0 20px;
text-decoration: none;
text-transform: uppercase;
}
.hero img {
width: 100%;
margin: 0 auto;
padding: 0;
}
.icons {
margin: 50px auto;
text-align: center;
}
.icons i {
height: 75px;
width: 75px;
color: #544B46;
border-radius: 10%;
background-color: #fff;
font-size: 40px;
margin: 0 auto;
cursor: pointer;
border: 2px #544B46 solid;
display: inline-block;
padding: 15px 15px;
}
.icons h1,
.icons p {
padding: 15px;
}
<body>
<header>
<nav class="container">
<div class="row">
<ul>
<li><a href=”#”>About us</a></li>
<li><a href=”#”>Mission</a></li>
<li><a href=”#”>Contact</a></li>
</ul>
</div>
</nav>
</header>
<section class="hero">
<div class="container">
<div class="row">
<img src="http://naturalnie.media.pl/test/train-long.jpg">
</div>
</div>
</section>
<section class="icons">
<div class="container">
<div class="row">
<div class="col-4">
<i class="fab fa-researchgate"></i>
<h1>Lorem ipsum</h1>
<p>Lorem ipsum.</p>
</div>
<div class="col-4">
<i class="fas fa-laptop-code"></i>
<h1>Lorem ipsum</h1>
<p>Lorem ipsum.</p>
</div>
<div class="col-4">
<i class="fas fa-cogs"></i>
<h1>Lorem ipsum</h1>
<p>Lorem ipsum.</p>
</div>
</div>
</div>
</section>
<section class="featured">
<div class="container">
<div class="row">
<div class="col-12">
<h1>FEATURED WORKS</h1>
</div>
</div>
</div>
</section>
</body>
Извините за отступы, здесь что-то новое.
Ответ №1:
Ваша проблема в том, что вы устанавливаете свой css-класс [class*="col-"]
с height: 150px;
помощью. Избавьтесь от требования к высоте, и оно вернется на место.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
width: 100%;
max-width: 1200px;
margin: 0 auto;
}
/* columns */
.col-1 {width: 8.33%;}... typical grid 1-12
/* offset */
.col-offset-1 {margin-left: 8.33%;}... same as above
/* clearfix */
row::before,
row::after {
content: "";
display: table;
clear: both;
}
[class*="col-"] {
float: left;
min-height: 1px;
/*height: 150px;*/
padding: 10px;
}
/* === */
header nav {
background-color: #544B46;
overflow: hidden;
}
header nav ul {
float: right;
margin: 0;
padding: 0;
list-style-type: none;
}
header nav ul li {
display:inline-block;
}
header nav ul li a {
line-height: 50px;
display: block;
color: #fff;
padding: 0 20px;
text-decoration: none;
text-transform: uppercase;
}
.hero img {
width: 100%;
margin: 0 auto;
padding: 0;
}
.icons {
margin: 50px auto;
text-align: center;
}
.icons i {
height: 75px;
width: 75px;
color: #544B46;
border-radius: 10%;
background-color:#fff;
font-size: 40px;
margin: 0 auto;
cursor: pointer;
border: 2px #544B46 solid;
display: inline-block;
padding: 15px 15px;
}
.icons h1,
.icons p {
padding: 15px;
}
<body>
<header>
<nav class="container">
<div class="row">
<ul>
<li><a href=”#”>About us</a></li>
<li><a href=”#”>Mission</a></li>
<li><a href=”#”>Contact</a></li>
</ul>
</div>
</nav>
</header>
<section class="hero">
<div class="container">
<div class="row">
<img src="http://naturalnie.media.pl/test/train-long.jpg">
</div>
</div>
</section>
<section class="icons">
<div class="container">
<div class="row">
<div class="col-4">
<i class="fab fa-researchgate"></i>
<h1>Lorem ipsum</h1>
<p>Lorem ipsum.</p>
</div>
<div class="col-4">
<i class="fas fa-laptop-code"></i>
<h1>Lorem ipsum</h1>
<p>Lorem ipsum.</p>
</div>
<div class="col-4">
<i class="fas fa-cogs"></i>
<h1>Lorem ipsum</h1>
<p>Lorem ipsum.</p>
</div>
</div>
</div>
</section>
<section class="featured">
<div class="container">
<div class="row">
<div class="col-12">
<h1>FEATURED WORKS</h1>
</div>
</div>
</div>
</section>
</body>