我有一个案例,我无法弄清楚如何解决。 我有一个Bootstrap 3部分,视频位于中心。 我需要在视频边缘的左边添加一个图像,在视频边缘的右边添加第二个图像。就像我在图片中计划的那样。
我尝试用position: absolute
执行此操作;一切都很好,但是当屏幕缩放时,会出现问题。如何使图像看起来像在图像上,但响应性是否一切正常?
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
<section id="trailer">
<div class="container">
<div class="row">
<div class="col-sm-12">
<img src="http://via.placeholder.com/170x400" alt="" class="trailer_wrapper--one img-responsive">
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="//www.youtube.com/embed/PGNiXGX2nLU"></iframe>
</div>
<img src="http://via.placeholder.com/170x300" alt="" class="trailer_wrapper--two img-responsive">
</div>
</div>
</div>
</section>
</html>
答案 0 :(得分:2)
您可以将sm-12
拆分为 2 + 8 + 2
.pl-0 {
padding-left: 0 !important;
}
.pr-0 {
padding-right: 0 !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section id="trailer">
<div class="container">
<div class="row">
<div class="col-xs-2 pr-0"> <img src="http://via.placeholder.com/170x400" alt="" class="trailer_wrapper--one img-responsive"> </div>
<div class="col-xs-8 pl-0 pr-0">
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="//www.youtube.com/embed/PGNiXGX2nLU"></iframe>
</div>
</div>
<div class="col-xs-2 pl-0"> <img src="http://via.placeholder.com/170x300" alt="" class="trailer_wrapper--two img-responsive"> </div>
</div>
</div>
</section>
答案 1 :(得分:0)
Hi Since you are using bootstrap, please align your code with bootstrap grid system,
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
<style>
img{
width:30px;height:30px;
}
.embed-responsive{
width:100%;
}
</style>
<section id="trailer">
<div class="container">
<div class="row">
<div class="col-sm-2 col-md-2 col-xs-2 col-lg-2">
<img src="http://via.placeholder.com/170x400" alt="" class="trailer_wrapper--one img-responsive"/>
</div>
<div class="col-sm-8 col-md-8 col-xs-8 col-lg-8">
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="//www.youtube.com/embed/PGNiXGX2nLU"></iframe>
</div>
</div>
<div class="col-sm-2 col-md-2 col-xs-2 col-lg-2">
<img src="http://via.placeholder.com/170x300" alt="" class="trailer_wrapper--two img-responsive">
</div>
</div>
</div>
</section>
</html>
You can style the height and width of image as per your need. This makes your website looks responsive and good looking.
Happy coding !! :)