【问题标题】:How to make a header full screen background?如何制作标题全屏背景?
【发布时间】:2015-06-27 21:59:36
【问题描述】:

我想用背景img全屏显示标题,但我遇到了问题

<header>
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <h1 class="logo"><a href="#">Super Tramp</a></h1>
                <h2 class="title">Sketch your next vacation route today</h2>
                <h3 class="sub-title">The Best Landing Page Travel Website for your vacation.</h3>
            </div>
            <div class="col-md-4 col-md-offset-4 col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-3">
                <form>
                    <p class="info">
                        Enter the required data and <br>
                        continue to choose the route.
                    </p>
                    <div class="form-group">
                        <input type="text" class="form-control" id="text" placeholder="Full Name">
                    </div>
                    <div class="form-group">
                        <input type="email" class="form-control" id="text" placeholder="Email Adress">
                     </div>
                     <div class="form-group">
                        <input type="text" class="form-control" id="text" placeholder="Phone Number">
                     </div>
                     <button type="button" class="btn btn-primary submit">Request Vacation</button>
                </form>
            </div>
        </div>
    </div>
</header>

这是 HTML 标记

header {
height: 100vh;
background: linear-gradient(
    rgba(0, 0, 0, 0.25),
    rgba(0, 0, 0, 0.25)
),url("../image/bg-header.jpg");
background-size: cover;
margin-bottom: 35px;

h1 {
    margin-top: 68px !important;
    text-align: center;

    a {
        color: #fff;
        font-family: 'montserrat-semibold';
        border: 3px solid #fff;
        padding: 11px 16px;
        letter-spacing: 8px;
        text-transform: uppercase;

        &:hover {
            text-decoration: none;
            color: #fff;
        }

        &:active {
            text-decoration: none;
            color: #fff;
        }
    }
}

h2 {
    text-align: center;
    color: #fff;
    font-family: 'montserrat-regular';
    letter-spacing: 5px;
    margin-top: 40px;
    font-size: 2.8em;
}

h3 {
    text-align: center;
    color: #fff;
    font-family: 'montserrat-regular';
    letter-spacing: 5px;
    margin-top: 26px;
    margin-bottom: 26px;
    font-size: 1.56em;
}

form {
    background-color: #fff;
    padding: 50px 15px;
    border-radius: 6px;
    padding-bottom: 25px;
    overflow: hidden;
}

div.form-group input, .form-control {
    height: 69px;
    margin-bottom: 25px;
    border: 1px solid #626262;
}

}

这是 CSS 标记

但问题是标题的一部分出来了,不知道如何解决问题

[http://gyazo.com/ef00bdc833ac1e1d26cd8423a132ecc2][1]

[1]: http://gyazo.com/ef00bdc833ac1e1d26cd8423a132ecc2 这是一张有问题的图片。

【问题讨论】:

  • 你能创建一个JSfiddle 吗?
  • 不完全确定如何使用 Bootstrap 执行此类操作,但我建议您查看 viewport-percentage lengths - 让元素填满屏幕只需使用 width: 100vw; height: 100vh;
  • 高度:100vh;从标题中删除它

标签: jquery html css less fullscreen


【解决方案1】:

试试这个,

html:-(分配的 ID)

<header id="thisHeader">
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <h1 class="logo"><a href="#">Super Tramp</a></h1>
                <h2 class="title">Sketch your next vacation route today</h2>
                <h3 class="sub-title">The Best Landing Page Travel Website for your vacation.</h3>
            </div>
            <div class="col-md-4 col-md-offset-4 col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-3">
                <form>
                    <p class="info">
                        Enter the required data and <br>
                        continue to choose the route.
                    </p>
                    <div class="form-group">
                        <input type="text" class="form-control" id="text" placeholder="Full Name">
                    </div>
                    <div class="form-group">
                        <input type="email" class="form-control" id="text" placeholder="Email Adress">
                     </div>
                     <div class="form-group">
                        <input type="text" class="form-control" id="text" placeholder="Phone Number">
                     </div>
                     <button type="button" class="btn btn-primary submit">Request Vacation</button>
                </form>
            </div>
        </div>
    </div>
</header>

CSS(不变)

添加一些 jQuery:-

$(document).reday(function(){
var clientHeight = $( window ).height();
  $('#thisHeader').css('height', clientHeight);

});

【讨论】:

  • 我试过了,但没有t work, on large device looks good but in small devices dont.
猜你喜欢
  • 2012-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多