简体   繁体   English

使图像在移动设备上的文本下方,而不是上方

[英]Make image go below text on mobile, not above

I have an image that is to the right of my text.我的文字右侧有一张图片。 That's working great.这很好用。 When the window size is decreased greatly, the text goes below my image, and the image is on top of it as expected.当窗口大小大大减小时,文本会在我的图像下方,而图像则按预期位于其顶部。 What I would like, however, is to change that to where the image goes below the text rather than above it when the window is resized to something like a mobile size.但是,我想要的是将窗口调整为移动大小之类的大小时,将其更改为图像位于文本下方而不是上方的位置。

Is this possible?这可能吗?

Here is my code:这是我的代码:

 .park-img { float: right; } .park-img img { display: inline-block; }
 <section class="tmt tmt-parking"> <a id="tmt-parking"></a> <div class="row"> <a name="parking"></a> <div class="park-img"> <img src="https://www.shsu.edu/academics/continuing-education/completion-ceremony/img/parking-map-1.jpg" style="height: 300px width: 300px"> </div> <div class="small-12 medium-6 columns large-6 columns"> <h2>Parking Information</h2> <p>The Sam Houston State University Parking Garage, located at 1730 Avenue I, is available 24 hours a day, seven days a week. Customers will pull an entry ticket at the entrance gates to enter. This entry ticket plus your credit card is needed to exit (Master Card, Visa, Discover, or American Express only). Your credit card will be charged based on the amount of time parked. <strong>CASH IS NOT ACCEPTED</strong>. Rates are $2.00/hour, with a $8.25/maximum fee per entry. Lost tickets will result in a $10.00 exit fee.</p> <p><strong>Do not park in spaces marked, “Reserved” between 7:30 am and 5:00 pm daily, as they are for semester contract holders only.</strong> </p> <p>Additional parking, at my charge, can be found in the following lots:</p> <ul> <li>33: Next to the Parking Garage (entrance/exit on Avenue I)</li> <li>35: At the corner of Avenue I and Bearkat Blvd (entrance/exit on Avenue I)</li> <li>36: Parallel parking along Avenue I</li> <li>56: In front of the George J. Beto Criminal Justice Center along 17th Street</li> </ul> </div> </div>

Here is fiddle if preferred如果喜欢,这里是小提琴

You need to use flexbox module for this.您需要为此使用flexbox 模块 You'll then be able to use the "order" property.然后您就可以使用“order”属性了。

 .flexbox { display: flex; flex-direction: column; } .item-first { order: 2; }
 <div class="flexbox"> <div class="item-first">I'm first, i guess?</div> <div class="item-second">I'm not first for sure</div> </div>

PS: Watch out, you can't put h2 tag in p tag. PS:注意,你不能把h2标签放在p标签中。

The easiest way is to create 2 img tags and use CSS media queries.最简单的方法是创建 2 个 img 标签并使用 CSS 媒体查询。 Put the second image under your text and make it display:none .将第二张图片放在文本下方并使其display:none Then specify a screen size in your CSS: if screen size < Npx , display: none for your first image and make the second image visible.然后在您的 CSS 中指定屏幕尺寸:如果屏幕尺寸 < Npx ,则为您的第一张图像display: none并使第二张图像可见。 You better set a new width and height to make it fit with your screen size!您最好设置一个新的宽度和高度以使其适合您的屏幕尺寸! Just use ids to differentiate the image tags and make your CSS as simple as possible.只需使用 id 来区分图像标签并使您的 CSS 尽可能简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM