gpt4 book ai didi

html - 回退 css 网格不工作

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

有人建议我通过“@support”以下列方式组合 css-grid 和 css-table:支持网格的浏览器应该使用网格,不支持网格的浏览器回退到默认的表格样式。

现在看来,我的网格布局无法建立,即使 ff 正在响应@support(例如,两个链接之一,谁应该更改网格模式已更改)。有人知道我的代码有什么问题吗?

这是我仍然得到的

[默认表回退] ( /image/bfQNl.jpg )

这是我想要的

[所需的网格布局] ( /image/C5v4v.jpg )

最佳答案

@supports 开始之前添加了 .wrapper-of-wrapper { display: none;}。我认为这会对您有所帮助:

html {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
display: table;
table-layout: fixed;
position: relative;
}

body {
display: table-cell;
vertical-align: middle;
text-align: center;
}

@media only screen and (max-width: 600px) {
/*some definitions */
}

.grid-G-and-H {
display: none;
max-height: 0;
overflow: hidden;
mso-hide: all;
}

.wrapper-of-wrapper {
display: none;
}

/*- - - - - - - - @supports - - - - - - - - - - - - */

@supports (display: grid) {
html {
box-sizing: border-box;
}
.wrapper-of-wrapper {
position: fixed;
width: 100%;
height: 100%;
display: flex;
flex-flow: column nowrap;
justify-content: center;
bottom: 0;
}
.wrapper {
height: auto;
display: grid;
-ms-grid;
-ms-grid-columns: 16% 16% 16%;
-ms-grid-rows: 10% 10% 10%;
flex: 0;
grid-column-gap: 7px;
grid-row-gap: 7px;
grid-template-columns: 16% 16% 16%;
justify-content: center;
/*horizontal*/
align-content: center;
/*vertical*/
grid-auto-flow: row dense;
}
.box {
justify-content: center;
align-items: center;
background: grey;
}
img {
max-width: 90%;
height: auto;
margin: 5px;
}
.a {
grid-column: 1 / span 2;
grid-row: 1 / span 2;
border: 5px solid red;
}
.b {
grid-column: 3;
grid-row: 1;
}
.c {
grid-column: 3;
grid-row: 2;
}
.d {
grid-column: 1;
grid-row: 3;
}
.e {
grid-column: 2;
grid-row: 3;
}
.f {
grid-column: 3;
grid-row: 3;
}
.grid-G-and-H {
display: block;
}
@media only screen and (max-width: 600px) {
/*some definitions*/
}
}
<div id="G">
<!--absolute positioned-->
<a href="link.html"><img style="margin: auto; width: 23px; height: 27px; left: 20px; position: absolute; top: 0pt; bottom: 0pt;" src="http://via.placeholder.com/23x27"></a>
</div>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div>
<a href="link.html"><img style="max-width: 600px; max-hight: 400px; width: 65%; height: auto; border: 5px solid red" src="http://via.placeholder.com/600x400"></a>
</div>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div id="H">
<!--absolute positioned-->
<a href="link.html"><img style="margin: auto; width: 23px; height: 27px; right: 20px; position: absolute; top: 0pt; bottom: 0pt;" src="http://via.placeholder.com/23x27"></a>
</div>
<!-- ## END OF DIVS FOR TABLE###### -->
<!-- ## BEGINNING OF DIVS FOR GRID ## -->
<div class="grid-G-and-H">
<div id="G_grid">
<a href="changed-link.html"><img style="margin: auto; width: 23px; height: 27px; left: 20px; position: absolute; top: 0pt; bottom: 0pt;" src="http://via.placeholder.com/23x27"></a>
</div>
</div>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div class="wrapper-of-wrapper">
<div class="wrapper">
<div class="box a" id="A">
<img style="color: red" src="http://via.placeholder.com/350x200">
</div>
<div class="box b" id="B">
<img src="http://via.placeholder.com/170x100">
</div>
<div class="box c" id="C">
<img src="http://via.placeholder.com/170x100">
</div>
<div class="box d" id="D">
<img src="http://via.placeholder.com/170x100">
</div>
<div class="box e" id="E">
<img src="http://via.placeholder.com/170x100">
</div>
<div class="box f" id="F">
<img src="http://via.placeholder.com/170x100">
</div>
</div>
</div>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div class="grid-G-and-H">
<div id="H_grid">
<a href="changed-link.html"><img style="margin: auto; width: 23px; height: 27px; left: 20px; position: absolute; top: 0pt; bottom: 0pt;" src="http://via.placeholder.com/23x27"></a>
</div>
</div>

关于html - 回退 css 网格不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50093521/

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