【发布时间】:2021-05-28 07:19:46
【问题描述】:
我一直在尝试仅使用 HTML 和 CSS 重新创建图片/设计,但在定位方面我一直卡住。 The image I'm trying to recreate
有人可以给我一些建议吗?
这是我的 CSS 代码。 我知道我搞砸了定位,但我没有任何其他想法
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&family=Lexend+Deca&display=swap');
.main{
width: 1440px;
background-color: hsl(233, 47%, 7%);
transform: translate(0%, 0%);
}
.inner{
width: fit-content;
height: fit-content;
border-radius: 10px;
border: purple 50px;
background-color: #333;
margin: 20%;
margin-top: 30%;
}
.texts{
background-color: hsl(244, 38%, 16%);
font-family: 'Lexend Deca', sans-serif;
width: 47.5%;
transform:translateY(60%);
height: 40%;
}
.mainhead{
color: hsl(0, 0%, 100%);
font-family: 'Inter', sans-serif;
}
.insights{
color: hsl(277, 64%, 61%);
}
.mainparagraph, .stats{
color: hsla(0, 0%, 100%, 0.75);
}
.stathead{
color: hsla(0, 0%, 100%, 0.6);
}
p {
font-size: 15px;
}
.image{
width:fit-content;
height: 40%;
background-color: hsl(277, 98%, 38%);
transform: translate(90%, -40%);
}
img {
opacity: 0.6;
}
<body>
<section class="main">
<section class="inner">
<section class="texts">
<h1 class="mainhead">
Get <span class="insights">insights </span>that help your business grow.
</h1>
<p class="mainparagraph">
Discover the benefits of data analytics and make better decisions regarding revenue, customer experience, and overall efficiency.
</p>
<section class="bottom">
<h1 class="stathead">10k+</h1>
<p class="stats">COMPANIES</p>
</section>
<section class="bottom">
<h1 class="stathead">314</h1>
<p class="stats">TEMPLATES</p>
</section>
<section class="bottom">
<h1 class="stathead">12M+</h1>
<p class="stats">QUERIES</p>
</section>
</section>
<section class="image">
<img src="images/image-header-desktop.jpg" alt="">
</section>
</section>
</section>
</body>
【问题讨论】:
-
这是一个开始,我试图将代码保持在最低限度,以便您可以理解它jsfiddle.net/dyj419na 在构建 UI 时,您首先将其分解为这样 i.stack.imgur.com/uXDI0.jpg 它会让您轻松合作
-
非常感谢!!我真的很感激,但你能向我解释一下整个 flex 概念吗?
-
或推荐我到哪里可以阅读到它
-
那里有很多文章,快速谷歌搜索可以让你开始,但当然你从 MDN 开始,我认为你多年来会经常访问 developer.mozilla.org/en-US/docs/Web/CSS/…跨度>
标签: html css css-position