将元素扩展到引导容器之外 [英] Extend an element beyond the bootstrap container

查看:74
本文介绍了将元素扩展到引导容器之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Bootstrap 4处理其中一个模型,并且容器内有一个不常见的元素,其背景超出了容器.不知道应该怎么做.我试图用以下位置来实现它:绝对的,但是我不喜欢它,因为在这种情况下缺乏响应性.

I'm currently working on one of mockups with using Bootstrap 4 and there's one uncommon element inside the container, which background is extending beyond container. Not sure how exactly this thing should be done. I was trying to implement it with position: absolute, but I'm not a fan of it because of broking responsivness in that case.

有问题的元素是带有背景的观看视频"文本.

The problematic element is "Watch the video" text with background.

非常感谢您的帮助.谢谢.

Would appreciate any help. Thanks.

/* VIDEO */
.video {
    padding: 70px 0;
    position: relative;
}
.video .video-wrapper p {
    font-size: 14px;
    line-height: 30px;
    font-style: italic;
    margin-top: 10px;
}

.video .description-wrapper h3 {
    font-size: 20px;
    line-height: 25px;
}
.video .description-wrapper .box {
    padding: 10px 15px;
}
.bg-colored {
    color: #fff;
    background-color: #0b3b52;
}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
    <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" href="styles.css">
    <title>Videos</title>
</head>
<body>
        <section class="video">

 
                <div class="container">
                    <div class="row">
                        <div class="col-md-5 video-wrapper">
                            <img src="https://i.imgur.com/mVWlLQt.png" class="img-fluid" alt="">
                            <p>Name video 5:45</p>
                        </div>
                        <div class="col-md-7 description-wrapper">
                           <div class="row align-items-center">
                               <div class="col-md-6 box">
                                   <h3>Keep your club organized online, 
                                        we save time and energy for you!
                                        </h3>
                               </div>
                               <div class="col-md-6 box bg-colored">
                                    <h3>Watch the video</h3>
                                </div>
                                <div class="col-md-12">
                                    <p>
                                    Managing a team could also be a hassle free and easy activity. 
                                    CRM42 is a web based platform with a user friendly interface, offering a comfortable and profitable experience while using it. Create your new management strategy and focus on getting the best results. 
                                    Your goal is now our goal!      
                                    </p>
                                    <p>
                                    CRM42 gives you a complete solution with a 360-degree view of your players, including complete management of their contracts, injuries, medicals, offers, past teams, even family members, bank accounts and all sponsors information.
                                    Accessible for your entire staff, anytime from anywhere.
                                    </p>
                                    <p>
                                            Let’s make something awesome together!
                                    </p>
                                </div>
                           </div>
                        </div>
                    </div>
                </div>
            </section>
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>

推荐答案

基本上,此已经回答了,但是我会回答,因为Bootstrap 4 flexbox与其他3.x回答不同.

Basically, this has already been answered, but I will answer since Bootstrap 4 flexbox is different than the other 3.x answer.

可以使用扩展到列外部的伪元素来完成:

It can be done with pseudo element that extends outside the column:

https://www.codeply.com/go/tXGn5pdD4A

.bg-colored:before {
    right: -999em;
    background:  #0b3b52;
    content: '';
    display: block;
    position: absolute;
    width: 999em;
    top: 0;
    bottom: 0;
}

这篇关于将元素扩展到引导容器之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆