gpt4 book ai didi

css - 这是 CSS : flex-direction row or width 100%? 中的第一个

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

我将主容器与 display:flexflex-direction:row 一起使用。我还使用了一些 width:100% 的子元素。

除了 Google pagespeed insights 之外,该页面似乎在所有经过测试的浏览器中都没有问题,而且 AdSense 响应式广告使容器比它必须的更宽。

我不确定这些是否已连接,但我不确定在将某些子元素的宽度设置为 100% 之前是否呈现了 flex 布局。

有人知道这两个 CSS 属性的顺序吗?

我已经创建了一个示例,但似乎我已经遇到了问题

body {
max-width: 1150px;
margin: 0 auto;
}

.header, .footer {
background-color: #eee;
border: 1px dotted #b76507;
padding: 10px 20px 0;
text-align: center;
}

*, :after, :before {
box-sizing: border-box;
}

article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary {
display: block;
}

.boxcontainer {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/*width: 100vw;*/
}

.article {
max-width: 832px;
width: 832px;
}

.subcontent1 {
background-color: #eee;
width: 1100px; /* external content */
}

.extra {
background-color: #FFFFFF;
border-left: 1px dotted #b76507;
max-width: 318px;
width: 318px;
display: none;
}

@media all and (min-width: 850px) {
.extra {
display: initial;
}
<body>
<header class="header">
header
</header>
<main class="boxcontainer">
<article class="content">
article
<div class="subcontent1">
sub sub sub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub sub sub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub subsub sub
</div>
</article>
<aside class="extra">
sidebarsidebar
</aside>
</main>
<footer class="footer">
footer
</footer>
</body>

http://codepen.io/anon/pen/pyBNoX

更新了示例代码以准确显示问题。侧边栏被推到主框之外只是因为内容很宽 - 即使它设置了最大宽度。

最佳答案


我刚刚遇到你的问题,我很乐意尝试为你解答。
通常 flex 会出现在 width 之前,在您想要设置为 100% 的元素上,当您使用 flex 时,请改用 100vh。
这方面的一个例子是:

header {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
flex-direction: column;

height: 100vh;
}

我知道这是有效的,因为我直接从我的一个网站的样式表中获取了它。

你可以做些什么来尝试加强它:

header {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
flex-direction: column;

height: 100vh;

-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}

如果这回答了您的问题,请告诉我,
詹姆斯。

关于css - 这是 CSS : flex-direction row or width 100%? 中的第一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37203079/

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