我目前正在尝试让我的网站响应。我网站的布局方式是,在桌面版本上,它是 2 个 col-6,并排排列,我网站部分(单页网站)的每一页都占据 100% 的宽度和高度,也就是1 页。为了缩放图像,每个 col-6 都有 100% 的高度,同样我的 background-size 设置为 100% 大小。这非常适合桌面版本。
问题是,当我缩小到平板电脑或手机时,每半页使用 col-12,我将它们堆叠在一起,而不是并排放置,100% 大小的图像 div 是在平板电脑上太大了,挤压了另一个 div(因为部分高度只有 100%)。在手机上它太小了,所以它在图像下面显示了一堆空白。
我觉得让它正确缩放的唯一方法是在容器上不设置高度,在 div 中使用 img 标签而不是背景图像,因为它只会占用与它一样多的空间需要,而不是任何额外的。然而,问题是现在它并没有填满它所在的整个图像 div,而是在侧面和底部留下空白空间。我试过设置不同的大小、设置等,但无论我做什么都不会填满它。它在平板电脑和手机上也做同样的事情。我怎样才能让它发挥作用?
它在桌面上应该是什么样子(这是带有背景图像)- http://i988.photobucket.com/albums/af6/jtbitt/24-inch-desktop-responsive_zps6mwocx8l.png
它在桌面上的样子(带有 img)- http://i988.photobucket.com/albums/af6/jtbitt/desktop%20version%20with%20img_zpsirzeqjy7.png
平板电脑(带背景图片)- http://i988.photobucket.com/albums/af6/jtbitt/tablet-stacking-improperly_zpsrxkz3ky3.png
平板电脑 (img) - http://i988.photobucket.com/albums/af6/jtbitt/tablet%20version%20with%20img_zps2lgo5d4x.png
手机(带背景图片)- http://i988.photobucket.com/albums/af6/jtbitt/mobile-stacking-improperly_zps604fz2oy.png
手机 (img) - http://i988.photobucket.com/albums/af6/jtbitt/mobile%20version%20with%20img_zpsqmqrw2ib.png
HTML -
<section id="about" ng-controller="aboutController">
<div class="container-fluid">
<div class="row about-row">
<div class="about-left col-xs-12 col-md-6">
<img src="assets/images/jay-ocean.jpg" class="col-xs-12"/>
</div>
<div class="about-right col-xs-12 col-md-6">
<div class="about-content">
<div class="about-content-title">
<h1><strong>I'M JAY.</strong></h1>
</div>
<div class="about-content-info">
<p ng-if="about.firstParagraph">An entrepenurial minded, Full Stack Developer. Whenever I'm up against a challenge that I care about, it gives me a rush. Focusing on the big picture is important to me, but I never forget the smaller details. Anything that is not challenging is boring, and makes me yawn. Anything that is seemingly impossible interests me a lot. I'm ready to get to work.</p>
<p ng-if="!about.firstParagraph">Currently seeking a Javascript position, using the MEAN stack, in New York City. Being innovative, ambitious, and hard working are values that are very important to me. I want to join a company that has similar values and has goals of reaching ridiculous levels of success, not just modest realistic ones. I love working with a solid team.</p>
</div>
<div class="about-button">
<button ng-if="about.firstParagraph" class="label label-success" ng-click="about.switchParagraph()">MORE =></button>
<button ng-if="!about.firstParagraph" class="label label-success"><a href="/portfolio">VIEW SKILLS</a></button>
</div>
<div class="about-personal-info">
<h4>Email: jaybittner@gmail.com</h4>
</div>
<div class="about-icon">
<a href="{{ profile.url }}" ng-repeat="profile in about.profiles"><img ng-src="{{ profile.icon }}" /></a>
</div>
</div>
</div>
</div>
</div>
</section>
CSS -
#about {
height: 100%;
width: 100%;
background: rgba(0,97,65,1);
background: -moz-linear-gradient(left, rgba(0,97,65,1) 0%, rgba(54,135,95,1) 7%, rgba(36,123,85,1) 22%, rgba(0,97,65,1) 53%, rgba(34,121,84,1) 76%, rgba(54,135,95,1) 90%, rgba(54,135,95,1) 100%);
background: -webkit-gradient(left top, right top, color-stop(0%, rgba(0,97,65,1)), color-stop(7%, rgba(54,135,95,1)), color-stop(22%, rgba(36,123,85,1)), color-stop(53%, rgba(0,97,65,1)), color-stop(76%, rgba(34,121,84,1)), color-stop(90%, rgba(54,135,95,1)), color-stop(100%, rgba(54,135,95,1)));
background: -webkit-linear-gradient(left, rgba(0,97,65,1) 0%, rgba(54,135,95,1) 7%, rgba(36,123,85,1) 22%, rgba(0,97,65,1) 53%, rgba(34,121,84,1) 76%, rgba(54,135,95,1) 90%, rgba(54,135,95,1) 100%);
background: -o-linear-gradient(left, rgba(0,97,65,1) 0%, rgba(54,135,95,1) 7%, rgba(36,123,85,1) 22%, rgba(0,97,65,1) 53%, rgba(34,121,84,1) 76%, rgba(54,135,95,1) 90%, rgba(54,135,95,1) 100%);
background: -ms-linear-gradient(left, rgba(0,97,65,1) 0%, rgba(54,135,95,1) 7%, rgba(36,123,85,1) 22%, rgba(0,97,65,1) 53%, rgba(34,121,84,1) 76%, rgba(54,135,95,1) 90%, rgba(54,135,95,1) 100%);
background: linear-gradient(to right, rgba(0,97,65,1) 0%, rgba(54,135,95,1) 7%, rgba(36,123,85,1) 22%, rgba(0,97,65,1) 53%, rgba(34,121,84,1) 76%, rgba(54,135,95,1) 90%, rgba(54,135,95,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#006141', endColorstr='#36875f', GradientType=1 );
background-repeat: no-repeat;
color: #101010;
}
/*#about .container-fluid, #about .row {
height: 100%;
}*/
/*.about-left {
height: 100%;
background-image: url('../../images/jay-ocean.jpg');
background-repeat: no-repeat;
background-size: 110%;
border-right: 3px solid #101010;
border-bottom: 3px solid black;
}*/
/*.about-left img {
height: 100%;
width: 100%;
object-fit: fill;
}*/
.about-right {
padding-top: 24vh;
padding-left: 3.4vw;
text-align: center;
}
.about-content {
width: 50%;
margin-left: auto;
margin-right: auto;
}
.about-content-title {
padding-bottom: -30px;
}
.about-content-title h1{
font-size: 3.1vw;
margin: 3px;
}
.about-content-info p {
font-size: 1vw;
word-spacing: 0.3vw;
}
.about-button button {
color: gray;
border: 1px solid #101010;
background-color: #101010;
font-size: 0.7vw;
}
.about-button a {
color: gray;
}
.about-personal-info h4 {
font-size: 1vw;
word-spacing: 0.3vw;
}
.about-icon img {
height: 3.5vh;
width: 1.75vw;
border-radius: 10px;
border: 1px solid #101010;
margin: 3px;
}
最佳答案
为什么不用 cover
值设置 background-size
属性?
关于html - 为什么我的图像不会扩展到 div 的完整大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32490428/