gpt4 book ai didi

html - CSS3 flex 属性不起作用?

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

我无法理解 2009 年推出的新 flex 模型。

主要语法发生了三个变化,对吧?我一直在阅读本教程,我认为它是最新的。 http://css-tricks.com/using-flexbox/

它在 chrome 中看起来不错,但它似乎不适用于 firefox。这个概念很简单,我有一个包含三篇文章的内容框,一篇文章左侧包含一张图片,一篇文章的主要内容(详细信息)居中且灵活,右侧是一个概述 Pane 。

如果我没理解错的话,这个 CSS 文件应该水平排列它们,同时展开详细信息框。Netbeans 告诉我“flex: 1”是一个未知属性。我做错了什么?

#content { /*Eigenlijke tekst/artikels*/
/* Oude chome, Android, Opera, IOS & safari syntax */
display: -webkit-box;
-webkit-box-orient: horizontal;

/* Oude firefox syntax */
display: -moz-box;
-moz-box-orient: horizontal;

/* Microsoft moet weer speciaal doen (IE) */
display: -ms-flexbox;
-ms-flex-orient: horizontal;

/* Nieuwe chome syntax */
display: -webkit-flex;
-webkit-flex-direction: row;

/* Nieuwste syntax */
display: flex;
}

article {
border: 1px solid black;
}
article[id="picture"] {
width: 150px;
padding: 10px;
margin-left: -20px;
}
#content > article[id="details"] {
-webkit-box-flex: 1;
-moz-box-flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
margin-left: 10px;
margin-right: 10px;
padding: 10px;
}
article[id="overview"] {
width: 225px;
padding: 10px;
}

这是 HTML 语法:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/detailpages.css">
<jsp:useBean id="al" scope="application" class="beans.actionlisteners" />
<script src="js/vendor/modernizr-2.6.2.min.js"></script>
</head>
<body>
<div id="page_wrapper">
<jsp:include page="header.jsp" />
<jsp:include page="navigation.jsp" />
<div id="content_wrapper">
<section id="content">
<article id="foto">
<img src="img/festivals/rock_werchter_2013.png"
alt="Rock Werchter 2013 - afbeelding" width="140px"
draggable="true" ondragstart="<% al.dragstart(); %>"
/>
Foto:&nbsp;&nbsp;
</article>
<article id="details">
<header>
<h2>Header van details</h2>
</header>
<p>Gegevens van festival</p>
<footer>
<h3>footer van details</h3>
</footer>
</article>
<article id="overzicht">
<header>
<h2>Lijsten</h2>
</header>
<p>Festivallijst & toevoegen</p>
<footer>
<h3>borderfactory dinges</h3>
</footer>
</article>
</section>
</div>
<hr style="width: auto; margin-left: 20px; margin-right: 20px;" />
<jsp:include page="footer.jsp" />
</div>
</body>
</html>

最佳答案

Firefox 实现 2009 规范(display:box)有很多错误。当一个元素成为一个 flex 容器 时,它应该表现得像一个与周围元素相关的 block 元素。 Firefox 实现更像是一个表格元素,因为它缩小到其子项的大小。添加显式宽度通常可以解决问题:

#content {
width: 100%;
}

关于html - CSS3 flex 属性不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15733466/

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