gpt4 book ai didi

html - CSS 显示内联属性对我不起作用

转载 作者:行者123 更新时间:2023-11-28 17:11:18 24 4
gpt4 key购买 nike

我正在尝试对齐 section 元素,如下所示

enter image description here

连续应用 display: inline-block; 属性,这就是我所看到的

enter image description here

出于某种原因,我似乎无法让它工作。我在下面包含了 HTML 和 CSS 代码。

如果有人能请教,那将是很大的帮助。

body {
background-color: #edeff2;
margin: 25px;
}

header {
margin-top: 15px;
padding-bottom: 8px;
padding-top: 8px;
background-color: #b8babc;
text-align: center;
color: #111; font-family: 'Helvetica Neue', sans-serif; font-size: 18px; font-weight: bold; letter-spacing: -1px; line-height: 1; text-align: center;
/*I copied the above style from https://wdexplorer.com/20-examples-beautiful-css-typography-design/ */
}

nav {
padding-bottom: 5px;
}

a {
text-decoration: none;
}

a:hover {
border: 1px solid;
}

h2 {
color: #111; font-family: 'Helvetica Neue', sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 1;

}

section {
display: inline-block;
padding-top: 30px;
padding-bottom: 30px;
float: left;
margin-right: 2%;
}

ul {
list-style-type: none;
}

progress {
color: #5ff4ef;
font-size: .7em;
line-height: 1.5em;
text-indent: .5em;
width: 15em;
height: 1.8em;
border: 1px solid #5ff4ef;
background: #5ff4ef;
}

details {
font-size: 1.2em;
color: #028402;
}

details p {
font-style: italic;
}

footer {
background-color: #b8babc;
font-size: 1.2em;
clear: both;
}

img {
width: 105px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Colleen</title>
<!-- ADD a LINK TO YOUR STYLE SHEET HERE!! -->
<link rel="stylesheet" href="style.css">
</head>

<body>
<header>
<h1>ALOK</h1>
<nav>
<a href = "">One</a>
<a href = "">Two</a>
<a href = "">Three</a>
<a href = "">Four</a>
</nav>
</header>
<section class="half">
<h2>Favorite Foods</h2>
<ul>
<li>Apples</li>
<li>Pizza</li>
<li>Crab</li>
<li>Chocolate Cake</li>
</ul>
</section>

<section class="half">
<h2>Achievements</h2>
<p> Progress in this course (100%)</100%><progress value = "1"></progress><br/>Progress in the Specialization (20%) <progress max = "5" value = "1"></progress><br/> Progress in life goals (67%)<progress max = "100" value = "67"></progress></p>
</section>

<section class = "whole">
<h2>More About Me</h2>
<details open><summary>My Childhood</summary>
<p>I grew up in Bangalore India. I lived near a Mango Grove and I used to steal a lot of them. </details>
</section>

<footer>
<p><img src = "http://www.intro-webdesign.com/images/newlogo.png" alt = "logo"/> This page was created by your name &amp; Colleen van Lent. To learn more about web design, visit <a href="http://www.intro-webdesign.com">Intro to Web Design</a>.</p>
</footer>

</body>

</html>

最佳答案

你需要添加一个宽度,比如30%:

body {
background-color: #edeff2;
margin: 25px;
}

header {
margin-top: 15px;
padding-bottom: 8px;
padding-top: 8px;
background-color: #b8babc;
text-align: center;
color: #111; font-family: 'Helvetica Neue', sans-serif; font-size: 18px; font-weight: bold; letter-spacing: -1px; line-height: 1; text-align: center;
/*I copied the above style from https://wdexplorer.com/20-examples-beautiful-css-typography-design/ */
}

nav {
padding-bottom: 5px;
}

a {
text-decoration: none;
}

a:hover {
border: 1px solid;
}

h2 {
color: #111; font-family: 'Helvetica Neue', sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 1;

}

section {
display: inline-block;
width: 30%;
padding-top: 30px;
padding-bottom: 30px;
float: left;
margin-right: 2%;
}

ul {
list-style-type: none;
}

progress {
color: #5ff4ef;
font-size: .7em;
line-height: 1.5em;
text-indent: .5em;
width: 15em;
height: 1.8em;
border: 1px solid #5ff4ef;
background: #5ff4ef;
}

details {
font-size: 1.2em;
color: #028402;
}

details p {
font-style: italic;
}

footer {
background-color: #b8babc;
font-size: 1.2em;
clear: both;
}

img {
width: 105px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Colleen</title>
<!-- ADD a LINK TO YOUR STYLE SHEET HERE!! -->
<link rel="stylesheet" href="style.css">
</head>

<body>
<header>
<h1>ALOK</h1>
<nav>
<a href = "">One</a>
<a href = "">Two</a>
<a href = "">Three</a>
<a href = "">Four</a>
</nav>
</header>
<section class="half">
<h2>Favorite Foods</h2>
<ul>
<li>Apples</li>
<li>Pizza</li>
<li>Crab</li>
<li>Chocolate Cake</li>
</ul>
</section>

<section class="half">
<h2>Achievements</h2>
<p> Progress in this course (100%)</100%><progress value = "1"></progress><br/>Progress in the Specialization (20%) <progress max = "5" value = "1"></progress><br/> Progress in life goals (67%)<progress max = "100" value = "67"></progress></p>
</section>

<section class = "whole">
<h2>More About Me</h2>
<details open><summary>My Childhood</summary>
<p>I grew up in Bangalore India. I lived near a Mango Grove and I used to steal a lot of them. </details>
</section>

<footer>
<p><img src = "http://www.intro-webdesign.com/images/newlogo.png" alt = "logo"/> This page was created by your name &amp; Colleen van Lent. To learn more about web design, visit <a href="http://www.intro-webdesign.com">Intro to Web Design</a>.</p>
</footer>

</body>

</html>

关于html - CSS 显示内联属性对我不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45590916/

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