2

I use Bootstrap 4. .top block should be 100% width and full screen height. .top-title should be in the middle of screen. .btn-scroll-down shold be down of the screen.

I want my page looks like enter image description here

HTML

<!-- top -->
        <div class="top js-top">
            <div class="container h-100">
                <div class="row h-100">

                    <div class="col-lg-12">
                        <h1 class="top-title">
                            <span class="top-title-1">text</span>
                            <span class="top-title-2">title</span>
                            <span class="top-title-3">text</span>
                        </h1>
                        <a href="" class="btn-redirect link-go-to-match">go</a>

                        <a href="#" class="btn-scroll-down js-btn-scroll-down"></a>
                    </div>
                </div>
            </div>
        </div>  
    <!-- /top -->

CSS

.btn-redirect {
    display: block;
    width: 301px;
    height: 57px;
    margin: 0;
    padding: 20px 0;
    cursor: pointer;
    -webkit-transition: background-color .3s linear;
    -moz-transition: background-color .3s linear;
    -ms-transition: background-color .3s linear;
    -o-transition: background-color .3s linear;
    text-align: center;
    text-transform: uppercase;
    color: #fff;
    border-radius: 10px;
    background-color: #ff780c;
    background-clip: padding-box;
}

.btn-scroll-down {
    position: absolute;
    bottom: 2%;
    left: 50%;
    display: block;
    width: 54px;
    height: 54px;
    margin-left: -27px;
    content: '';
    -webkit-transition: opacity .3s;
    -moz-transition: opacity .3s;
    -ms-transition: opacity .3s;
    -o-transition: opacity .3s;
    opacity: .5;
    border: 3px solid #fff;
    border-radius: 50%;
    background-clip: padding-box;
}

.top
{
    overflow: hidden;
    height: 100%;
    height: 100vh;
    min-height: 100%;
    min-height: 100vh;
    background-image: url(../images/bg_main.jpg);
    background-repeat: no-repeat;
    background-position: 50% 50%;
    background-size: cover;
    background-color: red;
}
.top .top-title
{
    padding-top: 35vh;
    text-align: center;
    text-transform: uppercase;
    color: #fff;
}
.top .top-title .top-title-1
{
    font-family: 'RobotoRegular';
    font-size: 3vh;
    display: block;
}
.top .top-title .top-title-2
{
    font-family: 'DaysOneRegular';
    font-size: 15vh;
    line-height: 1;
    display: block;
    margin-top: 2vh;
}
.top .top-title .top-title-3
{
    font-family: 'RobotoRegular';
    font-size: 3vh;
    display: block;
    margin-top: 2vh;
}
.top .link-go-to-match
{
    margin: 2vh auto 0 auto;
}

https://jsfiddle.net/LL0xm1jg/4/

But on the small screen .btn-redirect is placed on texts

enter image description here

I've tried to use flex properties from Bootstrap 4 but my attempts failed. Is there any way to make it work properly?

Carol Skelly
  • 351,302
  • 90
  • 710
  • 624
Heidel
  • 3,174
  • 16
  • 52
  • 84

1 Answers1

4

Use the flexbox way. Add a flexbox util class for the container to fill height. This flex-fill class will be included in Bootstrap 4.1.

.flex-fill {
    flex: 1 1 auto;
}

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

<div class="top js-top vh-100 bg-danger text-white d-flex">
    <div class="container flex-fill">
        <div class="row h-100 align-items-center py-1">
            <div class="col-lg-12 h-100 flex-fill d-flex flex-column align-items-center">
                <div class="my-auto text-center">
                    <h1 class="top-title">
                        <span class="top-title-1">text</span>
                        <span class="top-title-2">title</span>
                        <span class="top-title-3">text</span>
                    </h1>
                    <a href="" class="btn btn-redirect link-go-to-match">go</a>
                </div>
                <a href="#" class="btn-scroll-down js-btn-scroll-down"></a>
            </div>
        </div>
    </div>
</div>

Make the col-lg-12 a flexbox column using d-flex flex-column and then group the h1 and go button together in a div. Use my-auto to vertically center that div, and the button will naturally push to the bottom.

Carol Skelly
  • 351,302
  • 90
  • 710
  • 624
  • Thanks! But I also need to put arrow inside `.btn-scroll-down` http://prntscr.com/ir38lx I used pseudo-element `:before` with `position: absolute` for this purpose but now `.btn-scroll-down` doesn't have position property, so `:before` is not placed in right place. How to fix it? – Heidel Mar 14 '18 at 13:35
  • I forgot to copy this part of code in jsfiddle, sorry, my mistake ;-( It's updated fiddle https://jsfiddle.net/LL0xm1jg/7/ But I added `position: relative;` to `.btn-scroll-down` and it seems it fixed my problem with arrow. But I see other problem - in narrow screen `.btn-scroll-down` is changing its sizes http://prntscr.com/ir3kyh Is it fixible? – Heidel Mar 14 '18 at 13:53
  • 1
    It's because you have `height: 22px`.. just use `width: 36px; height:36px;` – Carol Skelly Mar 14 '18 at 14:04
  • nonono, it's :before element which has height:22px and width:36px, but the problem is .btn-scroll-down is becoming oval from round – Heidel Mar 14 '18 at 20:21
  • Oh, I see now! Thanks a lot for the help! – Heidel Mar 15 '18 at 06:28