【问题标题】:Place the image next to the text in big screens and stack them one below the other for smaller screens将图像放在大屏幕中的文本旁边,并将它们堆叠在另一个下方以用于较小的屏幕
【发布时间】:2020-10-19 20:29:22
【问题描述】:

我正在尝试建立自己的投资组合网站,我希望它具有响应性。对于“关于我”部分,我将我的图像放在左侧,在右侧放置一个关于我自己的简短介绍。现在,当我减小屏幕尺寸时,我希望将文本放在图像下方。知道如何做到这一点吗?任何帮助表示赞赏。

很抱歉没有早点发布代码。

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="styles1.css">
  </head>
<body>
  <div class="container2" id="container2">
    <div class="intro">
      <div class="column-img">
        <!-- My image goes here  -->
        <img src="" alt="">
      </div>
      <div class="column-txt">
        <h2>Hello.</h2>
        <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.</p>
      </div>
    </div>
  </div>
</body>
</html>




.container2 {
  position: relative;
  padding-top: 100px;
  text-align: center;
  padding-bottom: 80px;
  background-color: #A8D0e6;
}


.intro{
  background: #f76c6c;
  padding-left: 25px;
  padding-right: 25px;
  position: relative;
  box-sizing: border-box;
  border-radius: 4px;
  align-items: center;
  max-width: 100%;
  width: 70%;
  margin: auto;
  color: white;
  display: flex;
  height: 450px;
  transition: 0.5s;
}

.intro .column-img img{
  float: left;
  margin-right: auto;
  border-radius: 50%;
  display: block;
  margin-left: auto;
  width: 320px;
  height: 456px;
  padding: 30px;
}

【问题讨论】:

  • 请分享您的代码的简化版本,以便我们重现您的问题并为您提供帮助。
  • 方法有多种,可以使用css网格或者媒体查询

标签: html css python-3.x responsive-design web-site-project


【解决方案1】:

一种简单的方法是将图像和文本的容器/父级设置为 flex,如下所示:

display: flex;
flex-direction: column;

然后,对于您的每个项目:

.myimage {
   order: 1;
}

.mytext {
   order: 2;
}

但是,仍然建议您向我们展示您工作的代码 sn-p。

【讨论】:

    猜你喜欢
    • 2016-07-18
    • 1970-01-01
    • 2016-05-31
    • 1970-01-01
    • 2015-01-19
    • 2020-05-03
    • 2013-11-28
    • 2021-07-29
    • 1970-01-01
    相关资源
    最近更新 更多