gpt4 book ai didi

html - CSS:将部分的内部元素均匀地分成两部分

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

在我的体内,我有两个部分在一个列中彼此重叠(所有 flexbox )。它们将具有相同的属性,因此我使用了相同的 ID。唯一的区别是一个部分将在文本左侧显示图像,另一个将在右侧显示图像。

我有一个图像放在一个 div 旁边,里面有文本 (H2 & p)。我想让图像和 div 均匀地分割 flex box 部分的宽度。我尝试声明图像/div 宽度,但它也不会调整大小。有什么帮助吗?

HTML:

<body>
<!--Part 5-->
<section id="splitscreen">
<img src="/Images/white-hat.jpg"/>
<section>
<div>
<h2>Part 1</h2>
<p>some other text</p>
</div>
</section>
</section>

<!--Part 6-->
<section id="splitscreen">
<section>
<div>
<h2>Part 2</h2>
<p>More Text</p>
</div>
</section>
<img src="/Images/guaranteedseal.png"/>
</section>
</body>

CSS:

/*=====Part 5/6=====*/

#splitscreen{
display: -webkit-flex;
display: flex;

-webkit-flex-direction: row;
flex-direction: row;

-webkit-justify-content: center;
justify-content: center;

-webkit-align-self: center;
align-self: center;

margin: 25px 0px;
width: 100%;
min-height: 5vh;
}

#splitscreen img{
width = 30vw;
}

What I Have Now. Refer to http:www.graphicdisorder.com sections Concepts/Stickers. I'm attempting to mimic this layout

enter image description here

最佳答案

就像上面提到的那样,ID 应该用于唯一实例……只有一个标签……标签的多个“分组”的类。

让我知道这是否适合您?

Here is the JSFiddle Demo

截图:

enter image description here

//HTML

<!DOCTYPE html>
<html>
<head>
<link href="index.css" rel="stylesheet">
<script>
</script>
</head>
<body>
<section class="container">
<img src="http://static1.squarespace.com/static/5374c22ee4b0297decd522a5/t/537dcd58e4b007df5118ebf1/1400753542400/1.jpg?format=500w"/>
<div class="txt">
<h2>Part 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
</section>
<section class="container">
<div class="txt">
<h2>Part 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
<img src="http://static1.squarespace.com/static/5374c22ee4b0297decd522a5/t/55785b78e4b06b397737c826/1433951097309/?format=500w"/>
</section>
</body>
</html>

//CSS

.container{
display: -webkit-flex;
display: flex;

-webkit-justify-content: center;
justify-content: center;
}
.txt{
display: -webkit-flex;
display: flex;

-webkit-flex-direction: column;
flex-direction: column;

text-align: center;

-webkit-align-self: center;
align-self: center;

max-width: 200px;

}
img{
margin: 0 15px;
}

关于html - CSS:将部分的内部元素均匀地分成两部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31950206/

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