【问题标题】:I can't change the image in my website to responsive我无法将网站中的图片更改为响应式
【发布时间】:2021-10-31 04:03:12
【问题描述】:

我正在开发我的活动网站,目前我的“关于”部分中的图像存在响应性问题。我正在尝试更改我的图像,当我最小化浏览器时,图像也会调整为更小,但我找不到调整它并使其响应的方法。请帮助我。

 #abouts {
   background: #07414C;
   display: inline-block;
   width: 100%;
}
 
.about{
    padding: 100px 0px;
    background-color: #033541;
}
.about .about-picture img {
    width: 430px;
}
.about-text{
    width: 550px;
}
.main{
    width: 1130px;
    max-width: 95%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-around;
}
.about-text h2{
    color: white;
    font-size: 75px;
    text-transform: capitalize;
    margin-bottom: 20px;
}
.about-text h5{
    color: white;
    letter-spacing: 2px;
    font-size: 22px;
    margin-bottom: 25px;
    text-transform: capitalize;
}
.about-text p{
    color: white;
    letter-spacing: 1px;
    line-height: 28px;
    font-size: 18px;
    margin-bottom: 45px;
}



@media screen and (max-width: 768px) {
   .about .main {
     align-items: center;
     text-align: center;
     display: flex;
     flex-direction: column;
   }
   .about .about-picture img {
      max-width: 100%;
      height: auto;
   }
    .about .main .about-text h5  {
      width: 100%;
      font-size: 18px;
      text-align: center;
      padding-right: 1.2rem;
      padding-left: 1.2rem;
   }
   .about .main .about-text h2  {
      width: 100%;
      font-size: 50px;
      text-align: center;
      padding-right: 1.8rem;
      padding-left: 1.8rem;
   }
   .about .main .about-text p  {
      width: 100%;
      font-size: 15px;
      text-align: justify;
      padding-right: 2.8rem;
      padding-left: 2.8rem;
   }

 }
<!----about start---->
<div id = "abouts">
    <section class="about">
        <div class="main">
            <div class = "about-picture">
            <img src="aboutpic.jpg">
            </div>
            <div class="about-text">
                <h2>About Me</h2>
                <h5>word 1<span>, word 2, and word 3</span></h5>
                <p>Name, age, place. school where im studying. things that i love. motto.</p>
            </div>
        </div>
    </section>
</div>

【问题讨论】:

    标签: html css image minimize responsiveness


    【解决方案1】:

    max-width 应该以像素为单位定义,而不是简单的width

    而且足够流畅,不需要额外的媒体查询代码。

     .about .about-picture img {
            width: 100%;
            max-width: 430px;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-16
      • 1970-01-01
      • 2015-08-28
      • 2016-07-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多