gpt4 book ai didi

html - flexbox:CSS 框显示不正确

转载 作者:行者123 更新时间:2023-12-04 13:07:17 25 4
gpt4 key购买 nike

刚刚开始学习 flexbox 的教程,这是他们的代码:https://jsfiddle.net/bradtraversy/bu0ecodm/1/

我尝试创建一个非常基本的谷歌。由于某种原因,箱子和容器没有正确显示。无论我如何更改填充或边框大小/颜色,都不会发生任何变化

HTML:

<html>
<head>
<link rel="stylesheet" href="google-code.css">
<script src="google-code.js"></script>
</head>

<body>

<div class="left-container">
<div class="icon-box">
<h3> google </h3>
</div>
</div>

<div class="middle-container">
<div class="search-box">
<h1>search</h1>
<div class="tools-box">
<h1>tools</h1>
</div>
</div>
</div>

<div class="right-container">
</div>



</body>
</html>

CSS

.left-container{
display:flex;
}
.left-container div{

border: 1px #ccc solid;
padding: 10px;
}

.middle-container{
display:flex;
}
.middle-container div{
border: 1px #ccc solid;
padding: 30px;
}
.search-box{
flex:1;
order:2;
}
.tools-box{
flex:2;
order:1;
}

这是显示的内容: enter image description here

这是我所期望的: enter image description here

最佳答案

这是关于 flex-box 如何工作的重要资源: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

但我认为这更符合您根据图纸寻找的内容。

HTML

<html>
<head>
<link rel="stylesheet" href="google-code.css">
<script src="google-code.js"></script>
</head>

<body>
<div class='flex-box'>
<div class="left-container">
<div class="icon-box">
<h3> google </h3>
</div>
</div>

<div class="middle-container">
<div class="search-box">
<h1>search</h1>
</div>
<div class="tools-box">
<h1>tools</h1>
</div>
</div>
</div>



</body>
</html>

CSS

.flex-box{
display:flex;
}

.left-container > div{

border: 1px #ccc solid;
padding: 10px;
}

.middle-container{
display:flex;
flex-direction:column;
border: 1px #ccc solid;
width:100%;
}

.middle-container > div{
border: 1px #ccc solid;
margin: 0px 0px 5px 0px;
}

.search-box{
order:1;
}
.tools-box{
order:2;
}

显示

Display

关于html - flexbox:CSS 框显示不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68796285/

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