html - CSS div not listening to my max-width attribute
问题描述
EDIT: I think my code is fine. It was just the skew that made it a bit stretched out haha. Sorry
I normally would say my CSS skills are above average but this is seriously making me rethink that...
.our-work-container {
background: red;
display: flex;
flex-flow: column nowrap;
transform: skew(-12deg);
width: 100%;
margin: 0 auto;
}
.our-work-container .header-section {
display: flex;
flex-flow: row nowrap;
height: 260px;
}
.our-work-container .header-section .brand-square {
width: 350px;
min-width: 350px;
max-width: 350px;
background: yellow;
}
.our-work-container .header-section .header-text {
padding-left: 60px;
text-align: left;
color: white;
transform: skew(12deg);
}
.our-work-container .header-section .header-text h1 {
font-weight: 900;
font-size: 4em;
}
.our-work-container .header-section .header-text h2 {
font-family: Lora,serif!important;
font-size: 1.2em;
font-weight: 400;
}
<div class="our-work-container">
<div class="header-section">
<div class="brand-square"></div>
<div class="header-text">
<h1>Our Work</h1>
<div class="brand-line-break"></div>
<h2>Marketing is our passion, each project we take on is in collaboration with each of our team members, ensuring high quality marketing experiences.</h2>
</div>
</div>
<div class="projects"></div>
</div>
The colors are placeholders but can you guys tell me the reasoning why my yellow square(.brand-square) isnt listening to the max width attributes. When I inspect the element, I don't see anything that is messing with the styles.
My guess would be somehow flexbox is altering those values but I cant seem to figure out what.
Would really appreciate the insight. Thank you!
解决方案
只需删除width:350px
内部
.our-work-container .header-section .brand-square
类
在这里找到工作小提琴
http://jsfiddle.net/15xLs49j/2/
但作为建议,给出静态高度并不是一个好习惯,因为您的内容必须是响应式的,而 css 中的静态值会破坏响应性。
推荐阅读
- pandas - 如何将 Dataframe Multindex 中的值与相同索引的系列进行比较
- javascript - SyntaxError:意外的令牌,预期的“,”
- javascript - 如何将我的项目中的函数导入 script.JS
- java - 如何将一个类的ArrayList变成一个HashMap?
- hibernate-ogm - Hibernate-OGM (neo4j) 无人问津
- angular - 在 ngAfterViewInit 之后 createEmbeddedView 进入内容投影
- html - 按钮组,相对位置,在页脚上方
- sql - 在 Presto 地理空间函数中旋转线串
- c# - Dotnet restore 为 NuGet 包提供 301 错误
- angular - 如何禁用 Handsontable 热表正文中第一行的第一个正文字体样式?