繁体   English   中英

2 行响应式图像

[英]2 images in row responsive

我想在页面中央连续制作 2 张图像。 我的图像有不同的大小,但我希望它们位于中心和同一条线上。 首先,我尝试在框架 7 中使用 row 和 col-50

<div class="row">
    <div class="col-50"><img src="1.jpg"></div>
    <div class="col-50"><img src="2.jpg"></div>
</div>   

但它不能正常工作然后我用这种方式手动使用 css 样式

<div style="width:100%;display:inline-block;">
    <div style="width:50%;float:left">
        <img src="1.jpg" style="margin:auto;display:block" />
    </div>
    <div style="width:50%;float:left">
        <img src="2.jpg" style="margin:0 auto;display:block;"/>
        <span style="font-size: 40px; color: #4c4c4c; font-family: Calibri;">Logo company</span>
        <br />
        <span style="font-size: 12px; color: #4c4c4c; font-family: 'Helvetica Neue',sans-serif;">write here your brand</span>
    </div>
</div>

你也可以使用 flexbox,像这样

 .row { display: flex; align-items: center; justify-content: center; }
 <body style="background-color: #f6f6f6"> <div dir="ltr" class="page-content center" style="min-width: 400px; min-height: 400px; margin: auto; width: 58%; padding: 20px;"> <!-- Logo --> <!--<p style="text-align: center;">--> <div class="row"> <div class="col-50"> <img src="http://i64.tinypic.com/2ni7hjk.jpg" /> </div> <div class="col-50"> <img src="http://i68.tinypic.com/dunp0.png"/> <span style="font-size: 40px; color: #4c4c4c; font-family: Calibri;">logoeri</span> <br /> <span style="font-size: 12px; color: #4c4c4c; font-family: 'Helvetica Neue',sans-serif;">logo company is here</span> </div> </div> <!-- Header --> <div id="Header" style="font-family: 'Helvetica Neue',sans-serif; text-align: center; font-size: 30px; padding: 20px; color: white; background-color: #3eb780"> the header is here </div> <!-- Center Container --> <div style="font-family: 'Helvetica Neue',sans-serif; background: white;padding: 20px; font-size: 14px; font-family: Arial; direction: ltr; text-align: left;"> <p> 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. Why do we use it? 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> <!-- Footer --> <div style="text-align: center; color: #a2a2a2"> <div style="width: 90%; margin: auto; padding: 20px;"> Do not reply<br /> </div> </div> </div> </div>

请使用此代码并检查代码片段这是如何工作的。 我希望它对你有帮助。

 <style> .row img { display:inline-block; } .row{ text-align:center; } </style> <div class="row"> <img src="1.jpg"> <img src="2.jpg"> </div>

谢谢,

使用 display flex 和行内的相关容器,您将能够在图像内添加文本。

 .row{ width: 50%; display: flex; justify-content: center; margin: 0 auto; } .col-50{ width: 48.5%; text-align: center; } img{max-width: 100%;} .rel{position:relative;} .rel p{position:absolute; top:0; left:0; right:0;}
 <div class="row"> <div class="col-50"> <img src="https://placehold.it/200x200"></div> <div class="col-50"> <div class="rel"> <img src="https://placehold.it/200x300"> <p>TEXT INSIDE THE IMAGE</p> </div> </div> </div>

JSFiddle

暂无
暂无

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

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