html - 转换为移动 View 时在 html 中调整图像大小有问题

标签 html css twitter-bootstrap

我刚刚开始学习前端网络开发。我正在制作我的投资组合模型,但我在调整图像大小方面遇到了问题。我正在使用 Bootstrap 框架。当我使用具有 img-responsive 类的图像时,我上传的图像的高度和宽度会自动设置。由于我想自己设置高度,所以我更改了图像的高度(在 css 文件中)。但是,现在当我减小浏览器的宽度以查看我的投资组合在移动 View 中的外观时,宽度会调整大小但高度保持不变。这使图像看起来不成比例。我怎样才能解决这个问题?如果我不使用自定义高度,则在移动 View 中一切正常。

最佳答案

这在我的谷歌浏览器中对我有用。至于移动 View 和其他设备,此元标记有助于“meta name="viewport"content="width=device-width, initial-scale=1.0"(请参阅我的 html head 元素中的元标记)

hr {
	border-style: solid;
	border-width: 1px;
	width: 100%;
}
.featured-work {
	color: #BCBBBB;
}
.font {
	font-family: 'Lato', sans-serif;
	font-weight: 100;
	font-size: 60px;
}
.font1 {
	font-family: 'Lato', sans-serif;
	font-weight: 300;
	font-size: 20px;
}
.footer-title-fonts {
	color: #747704;
}
.name {
	margin-top: 66px;
}
.ulogo {
	margin-top: 40px;
}
.multiple-borders {
  box-shadow: 0px 0px 0px 7px black;
}
.multiple-borders1 {
  box-shadow: 0px 0px 0px 7px blue;
}
.multiple-borders2 {
  box-shadow: 0px 0px 0px 7px red;
}
.multiple-borders3 {
  box-shadow: 0px 0px 0px 7px green;
}
<!DOCTYPE html>
<html lang="en">
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Home Page</title>
      <link rel="stylesheet" href="css/normalize.css">
      <link rel="stylesheet" href="css/bootstrap.css">
      <link rel="stylesheet" href="css/style.css">
      <link href='http://fonts.googleapis.com/css?family=Lato:100,300,400' rel='stylesheet' type='text/css'>
  </head>
  <body>
    
    <div class="container"> <!-- start of container class -->

      <div class="row"> <!-- start of row class -->
          
                  <!-- udacity logo -->
        <div class="col-md-6">
          <img class="ulogo" src="images/logo.jpg" alt="udacity logo">
        </div>
                  <!-- end of udacity logo -->
                  <!-- start of name div -->
        <div class="col-md-6">
          <h1 class="font name text-uppercase text-right">Jane Doette</h1> 
          <h5 class="font1 text-uppercase text-right">Front-end ninja</h5>
        </div>
                  <!-- end of name div -->
      </div> <!-- end of row class -->
     
          <hr>
                   <!-- main image -->
      <div class="row">
          <div class="col-md-12">
            <img class="img-responsive multiple-borders" src="http://placekitten.com/1170/500" alt="filler image">
          </div>
      </div>
                  <!-- end of main image -->


                  <!-- bottom 3 images -->
        <div class="row"> <!-- start of row class -->
          
          <div class="col-md-12">
            <h3 class="featured-work">Featured Work</h3>
          </div>
                  <!-- First Image -->
          <div class="col-md-4"> 
            <img src="http://placekitten.com/550/400" class="img-responsive multiple-borders1" alt="filler image">
            <h2 class="footer-title-fonts text-center text-uppercase">Applify</h2>
            <h6 class="footer-title-fonts text-center">https://github.com/udacity/Appify/</h6>
          </div>
                  <!-- End of frst Image -->
                  
                  <!-- Second Image -->
          <div class="col-md-4"> 
            <img src="http://placekitten.com/550/400" class="img-responsive multiple-borders2" alt="filler image">
            <h2 class="footer-title-fonts text-center text-uppercase">Sunflower</h2>
            <h6 class="footer-title-fonts text-center">https://github.com/udacity/Sunflower/</h6>
          </div>
                  <!-- End of second Image -->
          
                  <!-- Third Image -->
          <div class="col-md-4">
            <img src="http://placekitten.com/550/400" class="img-responsive multiple-borders3" alt="filler image">
            <h2 class="footer-title-fonts text-center text-uppercase">Bokeh</h2>
            <h6 class="footer-title-fonts text-center">https://github.com/udacity/Bokeh/</h6>  
          </div>
                  <!-- End of Third Image -->
                  <!-- end of bottom 3 images -->

        </div> <!-- end of row class -->
    </div> <!-- end of container class -->
  </body>
</html>

enter image description here enter image description here

enter image description here

enter image description here

关于html - 转换为移动 View 时在 html 中调整图像大小有问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29305989/

相关文章:

jquery - 如何制作 jquery 的本地副本以便 html 页面正常工作?

html - CSS 在选择时更改按钮颜色

javascript - 如何使用 javascript/jquery 在打印页面上设置 div 内容的样式?

html - 按最后一个元素填充行中的剩余空间

html - CSS - 调整窗口大小时无法将 span 3 和 span9 保持在同一行

jquery - <p> 标签不显示在嵌套的 div 层中

HTML/CSS - 给 li 类

css - drupal 7 chrome 不加载 css 规则

html - 我想限制桌面屏幕上元素的大小

html - 如何使 nav-item 具有其内容所需的宽度以在一行中显示?