【问题标题】:CSS Grid or Columns? [closed]CSS 网格还是列? [关闭]
【发布时间】:2019-06-16 14:38:18
【问题描述】:

所以我已经布置好了我的移动版网站(见下面的草图)

但现在我在尝试实现我的桌面版本的设想目标时遇到了麻烦。我在油漆上做了一个速写,让你们了解我目前的情况。

问题是虽然我想在整个网站的中间保持我的图片和文本框彼此相邻。段落和页脚我可以自己做。只是我不知道最好的解决方案是让我的图片在左侧,文本在右侧,而我可以将其他所有内容放在底部并在那里做任何我想做的事情。

我希望图片(左侧)和文字(右侧)在页面中间。

【问题讨论】:

    标签: html css flexbox multiple-columns css-grid


    【解决方案1】:

    把你的图片和文字分别放在一个div中,然后在css下面给出那个div

    .parent{
      display:flex;
      justify-content:center;
      flex-wrap:wrap;
     }
     .parent div{
     height:200px;
     width:300px;}
     
     .img img{
      width:100%;
      height:100%;
     }
     
      
    <div class="parent">
    <div class="image">
    <img src="https://cdn.colorlib.com/shapely/wp-content/uploads/sites/12/2016/03/photo-1447834353189-91c48abf20e1-1-1.jpg"
              alt="">
    </div>
    <div class="text">
    <h2>About Us</h2>
              <p>Usage of the Internet is becoming more common due to rapid advancement of technology and the power of
                globalization. Societies are becoming more inter-connected. Thoughts from different</p>
                <a href="">READ MORE</a>
    
    </div>
    </div>

    }

    【讨论】:

    • 嘿,谢谢!我对你的代码唯一不符合我喜好的问题是我必须改变一些事情。所以这部分 .img img{ width: 100%;高度:100%;我必须通过删除 period img 来删除 .img 并将其保留为 img { 并将宽度和像素更改为 170px 而不是百分比。我什至在 .parent 部分添加了一个填充,为我的图片和文字提供了一个好地方。
    猜你喜欢
    • 2019-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-13
    • 1970-01-01
    • 1970-01-01
    • 2021-08-03
    • 1970-01-01
    相关资源
    最近更新 更多