标题背景图像高度不工作

时间:2015-03-28 01:41:48

标签: html css

当我有这张照片时,它只会达到一定的高度而且不会过去。如果你把它缩小它会变小,但是如果你让它变得更小,它就不会大于50px。

代码:

HMTL

  <body>
  <div class="header-img">
<div id="wrapper">   
   <!-- Sidebar -->
    <div id="sidebar-wrapper">
        <ul class="sidebar-nav">
            <li class="sidebar-brand">
                <a href="#">
                    Rx Programming
                </a>
            </li>
            <li>
                <a href="#">Calender</a>
            </li>
            <li>
                <a href="#">Achievements</a>
            </li>
            <li>
                <a href="#">Trainer</a>
            </li>
            <li>
                <a href="#">Social</a>
            </li>
            <li>
                <a href="#">Account</a>
            </li>
            <li>
                <a href="#">Contact</a>
            </li>
            <li>
                <a href="#">Sign Out</a>
            </li>
        </ul>
    </div>
    <!-- /#sidebar-wrapper -->

    <!-- Page Content -->
    <div id="page-content-wrapper">


        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">

                    <a href="#menu-toggle" class="btn btn-default btn-right"  id="menu-toggle">Menu</a>
                </div>
            </div>
        </div>

    </div>
    <!-- /#page-content-wrapper -->

</div>
</div>
<!-- /#wrapper -->

<!-- jQuery -->
<script src="js/jquery.js"></script>

<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>

<!-- Menu Toggle Script -->
<script>
$("#menu-toggle").click(function(e) {
    e.preventDefault();
    $("#wrapper").toggleClass("toggled");
});
</script>

CSS:

.btn .btn-default .btn-right {
padding: 20px;
color: red !important;
float: left;
}


.header-img {
background-image: url(../img/crossfitheader.jpg);
background-position: center;
background-repeat: no-repeat;
background-color: #222;
height: 100%

}

#wrapper {
padding-left: 0;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}

#wrapper.toggled {
padding-left: 250px;
}

#sidebar-wrapper {
z-index: 1000;
position: fixed;
left: 250px;
width: 0;
height: 100%;
margin-left: -250px;
overflow-y: auto;
background: #000;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}

#wrapper.toggled #sidebar-wrapper {
width: 250px;
}

#page-content-wrapper {
width: 100%;
position: absolute;
padding: 15px;
}

#wrapper.toggled #page-content-wrapper {
position: absolute;
margin-right: -250px;
}

/* Sidebar Styles */

.sidebar-nav {
position: absolute;
top: 0;
width: 250px;
margin: 0;
padding: 0;
list-style: none;
}

.sidebar-nav li {
text-indent: 20px;
line-height: 40px;
}

.sidebar-nav li a {
display: block;
text-decoration: none;
color: #999999;
}

.sidebar-nav li a:hover {
text-decoration: none;
color: #fff;
background: rgba(255,255,255,0.2);
}

.sidebar-nav li a:active,
.sidebar-nav li a:focus {
text-decoration: none;
}

.sidebar-nav > .sidebar-brand {
height: 65px;
font-size: 18px;
line-height: 60px;
}

.sidebar-nav > .sidebar-brand a {
color: #999999;
}

.sidebar-nav > .sidebar-brand a:hover {
color: #fff;
background: none;
}

@media(min-width:768px) {
#wrapper {
    padding-left: 250px;
}

#wrapper.toggled {
    padding-left: 0;
}

#sidebar-wrapper {
    width: 250px;
}

#wrapper.toggled #sidebar-wrapper {
    width: 0;
}

#page-content-wrapper {
    padding: 20px;
    position: relative;
}

#wrapper.toggled #page-content-wrapper {
    position: relative;
    margin-right: 0;
}
}

.btn .btn-default .btn-right {
padding: 20px;
color: red !important;
}

#menu-toggle {
padding: 20px;
color: red !important;
}

1 个答案:

答案 0 :(得分:0)

你的问题很不清楚,我不确定你在问什么,虽然我假设你试图在窗户尺寸扩大或缩小时放大图像?

样式表中的简单行可以解决这个问题(如果这是你要问的那个......)

img{max-width:100%;height:auto;}

所有剂量都自动设定图像的高度,并为其提供响应质量。