首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在列表组中的同一行上对齐文本和图像

在列表组中的同一行上对齐文本和图像
EN

Stack Overflow用户
提问于 2018-05-17 06:19:11
回答 1查看 1.7K关注 0票数 1

大家好,所以我正在制作一个网站作为一个项目,在其中一个部分,我正在放置一个列表组与项目的名称,并在右边,该项目的形象。我已经使用了Pingendo,但是文本与图像不对齐。

这是我有自动取款机的代码:

代码语言:javascript
复制
<div class="container">
<div class="row">
  <div class="col-sm-2"> </div>
  <div class="col-sm-8">
    <!-- Page Content -->
    <div class="container">
      <div class="row text-center text-lg-left">
        <div class="col-md-12">
          <div class="list-group my-3">
            <a href="#" class="list-group-item list-group-item-action flex-column align-items-start">
              <div class="w-100">
                <h4 class="mb-1 text-center">Arduino Uno</h4>
              </div>
              <img class="d-block float-right img-thumbnail img-fluid" src="https://pingendo.com/assets/photos/wireframe/photo-1.jpg" width="150" height="150" > </a>
            </a>

            <a href="#" class="list-group-item list-group-item-action flex-column align-items-start">
              <div class="w-100">
                <h5 class="mb-1 text-center">Breadboard</h5>
              </div>
              <img class="d-block float-right img-thumbnail img-fluid" src="https://pingendo.com/assets/photos/wireframe/photo-1.jpg" width="60" height="60" > </a>
            </a>

            <a href="#" class="list-group-item list-group-item-action flex-column align-items-start">
              <div class="w-100">
                <h5 class="mb-1 text-center">Product</h5>
              </div>
              <img class="d-block float-right img-thumbnail img-fluid" src="https://pingendo.com/assets/photos/wireframe/photo-1.jpg" width="60" height="60" > </a>
            </a>
          </div>

这是它在网站上的样子:

基本上,我要做的是把文本和图像放在同一条线上,这样我就不会在顶部和下面的图像上看到文本。

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-17 06:25:33

.list-group-item中删除‘.flex列’类,并添加'.d-flex‘。

还可以从代码中删除重复关闭的a标记。

代码语言:javascript
复制
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="row">
  <div class="col-sm-2"> </div>
  <div class="col-sm-8">
    <!-- Page Content -->
    <div class="container">
      <div class="row text-center text-lg-left">
        <div class="col-md-12">
          <div class="list-group my-3">
            <a href="#" class="list-group-item list-group-item-action d-flex   align-items-start">
              <div class="w-100">
                <h4 class="mb-1 text-center">Arduino Uno</h4>
              </div>
              <img class="d-block float-right img-thumbnail img-fluid" src="https://pingendo.com/assets/photos/wireframe/photo-1.jpg" width="60" height="60" > </a>
           

            <a href="#" class="list-group-item list-group-item-action d-flex    align-items-start">
              <div class="w-100">
                <h5 class="mb-1 text-center">Breadboard</h5>
              </div>
              <img class="d-block float-right img-thumbnail img-fluid" src="https://pingendo.com/assets/photos/wireframe/photo-1.jpg" width="60" height="60" > </a>
          

            <a href="#" class="list-group-item list-group-item-action d-flex  align-items-start">
              <div class="w-100">
                <h5 class="mb-1 text-center">Product</h5>
              </div>
              <img class="d-block float-right img-thumbnail img-fluid" src="https://pingendo.com/assets/photos/wireframe/photo-1.jpg" width="60" height="60" > </a>
            
          </div>

如果你想把文字和图像放在中间

代码语言:javascript
复制
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="row">
  <div class="col-sm-2"> </div>
  <div class="col-sm-8">
    <!-- Page Content -->
    <div class="container">
      <div class="row text-center text-lg-left">
        <div class="col-md-12">
          <div class="list-group my-3">
            <a href="#" class="list-group-item list-group-item-action d-flex   align-items-center">
              <div class="w-100">
                <h4 class="mb-0 text-center">Arduino Uno</h4>
              </div>
              <img class="d-block float-right img-thumbnail img-fluid" src="https://pingendo.com/assets/photos/wireframe/photo-1.jpg" width="60" height="60" > </a>
           

            <a href="#" class="list-group-item list-group-item-action d-flex align-items-center">
              <div class="w-100">
                <h5 class="mb-0 text-center">Breadboard</h5>
              </div>
              <img class="d-block float-right img-thumbnail img-fluid" src="https://pingendo.com/assets/photos/wireframe/photo-1.jpg" width="60" height="60" > </a>
          

            <a href="#" class="list-group-item list-group-item-action d-flex  align-items-center">
              <div class="w-100">
                <h5 class="mb-0 text-center">Product</h5>
              </div>
              <img class="d-block float-right img-thumbnail img-fluid" src="https://pingendo.com/assets/photos/wireframe/photo-1.jpg" width="60" height="60" > </a>
            
          </div>

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50384573

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档