gpt4 book ai didi

html - 主页部分布局

转载 作者:行者123 更新时间:2023-11-28 16:16:38 25 4
gpt4 key购买 nike

我正在实现一个新网站。我附上了一张图片,说明我希望它成为我主页的基础。我问你创建这三个彩色部分的最佳方法是什么。

要插入标题的第一个蓝色。第二个带有黑色边框的浅蓝色,其中包含名称。其余的浅灰色,我将在其中添加一个包含输入框的表格,并在下方添加文本。

我声明我对标题、表格、文本、输入框等的格式化没有问题。

我只是无法得到像图中那样的三个部分的效果。我要么尝试使用 div,但我认为这不是最佳解决方案,因为我得到了不需要的边距。

你会怎么做?

谢谢 :)

.div0 {
background-color: red;
margin-top: 0%;
margin-bottom: 0%;
}

.title1 {
font-family: Arial;
font-weight: normal;
color: black;
font-size: 428%;
margin-top: 0.7%;
margin-bottom: 0%;
text-align: center;
bgcolor: red;
}

.td1 {
text-align: center;
}

.div1 {
background-color: blue;
margin-top: 0%;
margin-bottom: 0%;
}
<BODY>

<div class="div0">
<H1 class="title1">
Title
</H1>
</div>

<div class="div1">
<table width="96%" align="center">
<tr class="tr1">
<td class="td1" width="1/7">
Name1
</td>
<td class="td1" width="1/7">
Name2
</td>
<td class="td1" width="1/7">
Name3
</td>
<td class="td1" width="1/7">
Name4
</td>
<td class="td1" width="1/7">
Name5
</td>
<td class="td1" width="1/7">
Name6
</td>
<td class="td1" width="1/7">
Name7
</td>
</tr>
</table>
</div>
<div class="div2">

</div>

</BODY>

enter image description here

最佳答案

类似的最小标记和 css,使用 css 网格和 flexbox,或多或少像这样:

body {
margin: 0;
font-family: sans-serif;
}

.main {
display: grid;
grid-template-rows: 120px max-content 1fr;
min-height: 100vh;
}

.header {
display: flex;
justify-content: center;
align-items: center;
background-color: blue;
color: yellow;
}

.header__title {
text-transform: uppercase;
}

.navbar {
display: flex;
background: lightblue;
border-top: 2px solid;
border-bottom: 2px solid;
}

.navbar__item {
flex-grow: 1;
padding: 6px 12px;
text-align: center;
text-transform: capitalize;
text-decoration: none;
color: black;
}

.content {
background: silver;
}
<main class="main">

<header class="header">
<h1 class="header__title">Title</h1>
</header>

<nav class="navbar">
<a href="#" class="navbar__item">item</a>
<a href="#" class="navbar__item">item</a>
<a href="#" class="navbar__item">item</a>
<a href="#" class="navbar__item">item</a>
<a href="#" class="navbar__item">item</a>
<a href="#" class="navbar__item">item</a>
<a href="#" class="navbar__item">item</a>
</nav>

<article class="content">

</article>
</main>

我建议您稍微研究一下 html5 语义标记,以帮助您了解在适当的上下文中在哪里使用每种标记。

关于html - 主页部分布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58440910/

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