当窗口的宽度降到768px以下时,我希望水平相册图像和文本内容进行转换,以使图像显示在相册文本下方,但在以下lorem ipsum文本上方。我在下面尝试了CSS代码,但没有用。当前,当窗口降到678px以下时,图像仍位于右侧。
https://jsfiddle.net/x1hkzrvw/3/
@media screen{
.image{
width:20%;
float: right;
border-radius:50%;
}
}
@media(max-width:768px) {
.image{
display: flex;
flex-wrap: wrap;
}
}
答案 0 :(得分:1)
在CSS下方添加
p {
display: flex;
flex-wrap: wrap;
}
p img {
order: 2
}
.image {
width: 50%;
height: 100px;
}
@media screen {
.image {
width: 20%;
float: right;
border-radius: 50%;
display: flex;
}
}
@media(max-width:768px) {
p {
display: flex;
flex-wrap: wrap;
}
p img {
order: 2
}
.image {
width: 50%;
height: 100px;
}
}
<div>
<p>
<img src="https://sample-videos.com/img/Sample-jpg-image-500kb.jpg" alt="Italian Trulli" class="image"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the
1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the
1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic
typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software. It is a long established fact that a reader will
be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable
English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes
by accident, sometimes on purpose (injected humour and the like). It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less
normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem
ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p>
</div>