css - 换行后修改 CSS 的行为
问题描述
如您所见,左边的图像粘在右边的 div 上,但是一旦右边的 div 包裹并放在图片下方,图像就会留在左边。我想让图片和第二个 div (下面,换行后)大小相同,只匹配水平大小。(由于某种原因,图片没有显示,但它是 800x500px 的图片)。
::-webkit-scrollbar {
width: 10px;
height: 10px;
}
::-webkit-scrollbar-track {
background: #91897b;
}
::-webkit-scrollbar-track:hover {
background: #ccb288;
}
::-webkit-scrollbar-thumb {
background: #e8aa45;
}
::-webkit-scrollbar-thumb:hover {
background: #f4a11a;
}
img {
max-width:100%;
max-height:500px;
}
.flex-container {
display: flex;
background-color: DodgerBlue;
flex-direction: row;
flex-wrap: wrap;
flex-grow:1;
}
.flex-container > div {
background-color: #fafafa;
width:auto;
height:100%margin: 1px;
font-size: 30px;
}
.caja-scroll{
overflow-y:auto;
background-color:#fafafa;
border-color: coral;
width:100%;
height:100%;
max-width:100%;
max-height:500px;
flex-shrink:5;
}
.bordes_gallery {
border-style:solid;
max-width:100%;
flex-grow: 1;
margin: 1px;
}
.gallery_item {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
max-height:100px;
border-style:dotted;
}
.gallery_item > #imagen {
order: 1;
flex-basis: 100px;
align-items:center;
justify-content:center;
}
.gallery_item > #texto {
order: 2;
align-items:center;
justify-content:center;
margin-left:5px;
}
<body>
<div class="flex-container">
<div style="order: 1; flex-basis: content; align-items:center; justify-content:flex-start; display: flex;">
<img src="http://kb4images.com/images/usa-wallpaper/36955559-usa-wallpaper.jpg"></img>
</div>
<div style="order: 2; flex-grow: 1; flex-basis: 28rem; max-height:500px; justify-content:flex-start; flex-shrink: 0;">
<div class="caja-scroll">
<div class="col-md-12 bordes_gallery">
<div class="gallery_item ">
<div id="imagen">
<img style="max-width:100px;" src="http://www.catolica.edu.sv/wp-content/uploads/2016/01/moodle-200x200.jpg">
</div>
<div id="texto">asdfadfs</div>
</div>
<div class="gallery_item ">
<div id="imagen">
<img style="max-width:100px;" src="http://www.catolica.edu.sv/wp-content/uploads/2016/01/moodle-200x200.jpg">
</div>
<div id="texto">asdfadfs</div>
</div>
<div class="gallery_item ">
<div id="imagen">
<img style="max-width:100px;" src="http://www.catolica.edu.sv/wp-content/uploads/2016/01/moodle-200x200.jpg">
</div>
<div id="texto">asdfadfs</div>
</div>
<div class="gallery_item ">
<div id="imagen">
<img style="max-width:100px;" src="http://www.catolica.edu.sv/wp-content/uploads/2016/01/moodle-200x200.jpg">
</div>
<div id="texto">asdfadfs</div>
</div>
<div class="gallery_item ">
<div id="imagen">
<img style="max-width:100px;" src="http://www.catolica.edu.sv/wp-content/uploads/2016/01/moodle-200x200.jpg">
</div>
<div id="texto">asdfadfs</div>
</div>
<div class="gallery_item ">
<div id="imagen">
<img style="max-width:100px;" src="http://www.catolica.edu.sv/wp-content/uploads/2016/01/moodle-200x200.jpg">
</div>
<div id="texto">asdfadfs</div>
</div>
</div>
</div>
</div>
</body>
解决方案
这对你有用吗?
::-webkit-scrollbar {
width: 10px;
height: 10px;
}
::-webkit-scrollbar-track {
background: #91897b;
}
::-webkit-scrollbar-track:hover {
background: #ccb288;
}
::-webkit-scrollbar-thumb {
background: #e8aa45;
}
::-webkit-scrollbar-thumb:hover {
background: #f4a11a;
}
img {
max-width:100%;
max-height:500px;
}
.flex-container {
display: flex;
background-color: DodgerBlue;
flex-direction: row;
flex-wrap: wrap;
flex-grow:1;
}
.flex-container > div {
background-color: #fafafa;
width:auto;
height:100%margin: 1px;
font-size: 30px;
}
.caja-scroll{
overflow-y:auto;
background-color:#fafafa;
border-color: coral;
width:100%;
height:100%;
max-width:100%;
max-height:500px;
flex-shrink:5;
}
.bordes_gallery {
border-style:solid;
max-width:100%;
flex-grow: 1;
margin: 1px;
}
.gallery_item {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
max-height:100px;
border-style:dotted;
}
.gallery_item > #imagen {
order: 1;
flex-basis: 100px;
align-items:center;
justify-content:center;
}
.gallery_item > #texto {
order: 2;
align-items:center;
justify-content:center;
margin-left:5px;
}
@media screen and ( max-width: 1263px) {
.flex-container>div:nth-child(1){width:100%;}
.flex-container>div:nth-child(1)>img{width:100%;}
.flex-container {max-width:800px; margin: auto;}
}
<div class="flex-container">
<div style="order: 1; flex-basis: content; align-items:center; justify-content:flex-start; display: flex;">
<img src="http://kb4images.com/images/usa-wallpaper/36955559-usa-wallpaper.jpg"></img>
</div>
<div style="order: 2; flex-grow: 1; flex-basis: 28rem; max-height:500px; justify-content:flex-start; flex-shrink: 0;">
<div class="caja-scroll">
<div class="col-md-12 bordes_gallery">
<div class="gallery_item ">
<div id="imagen">
<img style="max-width:100px;" src="http://www.catolica.edu.sv/wp-content/uploads/2016/01/moodle-200x200.jpg">
</div>
<div id="texto">asdfadfs</div>
</div>
<div class="gallery_item ">
<div id="imagen">
<img style="max-width:100px;" src="http://www.catolica.edu.sv/wp-content/uploads/2016/01/moodle-200x200.jpg">
</div>
<div id="texto">asdfadfs</div>
</div>
<div class="gallery_item ">
<div id="imagen">
<img style="max-width:100px;" src="http://www.catolica.edu.sv/wp-content/uploads/2016/01/moodle-200x200.jpg">
</div>
<div id="texto">asdfadfs</div>
</div>
<div class="gallery_item ">
<div id="imagen">
<img style="max-width:100px;" src="http://www.catolica.edu.sv/wp-content/uploads/2016/01/moodle-200x200.jpg">
</div>
<div id="texto">asdfadfs</div>
</div>
<div class="gallery_item ">
<div id="imagen">
<img style="max-width:100px;" src="http://www.catolica.edu.sv/wp-content/uploads/2016/01/moodle-200x200.jpg">
</div>
<div id="texto">asdfadfs</div>
</div>
<div class="gallery_item ">
<div id="imagen">
<img style="max-width:100px;" src="http://www.catolica.edu.sv/wp-content/uploads/2016/01/moodle-200x200.jpg">
</div>
<div id="texto">asdfadfs</div>
</div>
</div>
</div>
</div>
推荐阅读
- c# - Visual Studio wcf客户端c#SOAP evenlope方法名称不同大小写
- angular - 我如何解析构造函数的所有参数
- java - Spring boot 是否提供任何用于生成覆盖率报告的内部库
- reactjs - ReactDOM 你好世界
- oracle - 使用 If-Else 语句从 ODI 调用 Oracle PL/SQL 排序过程
- excel - 将数据从工作表复制到具有动态范围的新工作簿
- unit-testing - 单元测试:如何在调用 vuex 中的函数的输入上正确触发触发事件?
- xamarin - 需要转换 FontSize
- c++ - 叉积函数给出非常小的值,c ++
- javascript - 是否有在委托事件选择器中放置多个子元素的快捷方式?