简体   繁体   English

如何使图像向左并向右跨<center> ?

[英]How to make image left and span right on <center>?

I want to make an image left and a <span class="badge badge-primary">v 2.1</span> on right,all these items are on <center> .我想在左边制作一个图像,在右边制作一个<span class="badge badge-primary">v 2.1</span> ,所有这些项目都在<center>

code:代码:

<center><div class="card" style="margin-top: 5px; border-style: solid;
  border-color: grey;
  border-radius: 4px; border-width: 4px;">
  <img src="../install/images/brand/logo_wide.webp" alt="Thos Host Billing Software"><span class="badge badge-primary">v 2.1</span>
  <div class="container">
    // something    
  </div>
</div>

<center> tag is obsolete and shouldn't be used. <center>标签已过时,不应使用。 Use flexbox instead because it's much easier.改用 flexbox 因为它更容易。

Flexbox documentation: https://getbootstrap.com/docs/4.4/utilities/flex/ Flexbox 文档: https ://getbootstrap.com/docs/4.4/utilities/flex/

Check out my demo.看看我的演示。 If you don't use align-items-* class you need to wrap both <img> and <span> in <div> because otherwise it will be stretched vertically.如果您不使用align-items-*类,则需要将<img><span>都包裹在<div> ,否则它将被垂直拉伸。

 img{height:100px}
 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> <div class="d-flex justify-content-center align-items-center"> <img src="https://img.icons8.com/material/4ac144/256/camera.png" alt=""> <span class="badge badge-primary">v 2.1</span> </div>

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

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