-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfull-width-bg.html
More file actions
248 lines (214 loc) · 10.4 KB
/
full-width-bg.html
File metadata and controls
248 lines (214 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<title>Full Width BG</title>
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="icon" type="image/png" href="assets/images/favicon.png">
<link href="assets/styles/bootstrap.min.css" rel="stylesheet">
<link href="assets/styles/bootstrap-theme.min.css" rel="stylesheet">
<link href="assets/styles/flexslider.css" rel="stylesheet">
<link href="assets/styles/owl.carousel.min.css" rel="stylesheet">
<link href="assets/styles/owl.theme.default.min.css" rel="stylesheet">
<link href="assets/styles/font-awesome.min.css" rel="stylesheet">
<link href="assets/styles/hover-min.css" rel="stylesheet">
<link href="assets/styles/animate.css" rel="stylesheet">
<link href="assets/styles/custom.css" rel="stylesheet">
<link href="assets/styles/responsive.css" rel="stylesheet">
<style>
.full-bg-img{
background-image: url('assets/images/slide-1.jpg'); background-repeat: no-repeat;
/*background-size: contain;*/
background-size: cover;
width: 100%;
height: 0;
padding-top: 40.625%;
/*
formula
(img-height / img-width * width)
>> in this case >>>
(650 / 1600 * 100)
*/
}
</style>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!--
.sticky-footer sticks footer to bottom
.navbar-fixed-top-custom sticks header to top and adds padding from top for content
.pg-wrapper is like second body coz we can not apply classes to body - but we can have div with .pg-wrapper in every partial pages that will be called in main index template
-->
<div class="pg-wrapper sticky-footer navbar-fixed-top-custom">
<!-- Fixed navbar -->
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Home</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Owl Carousel <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="carousel.html">Single / Random Height / images</a></li>
<li><a href="carousel-2.html">Single / Screen Height / BGs</a></li>
<li><a href="carousel-3.html">Multiple Sliders / images</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Flex Slider <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="flexslider-1.html">Single / Random Height / images</a></li>
<li><a href="flexslider-2.html">Single / Screen Height / BGs</a></li>
<li><a href="flexslider-3.html">Multiple Sliders / images</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Slick Slider <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="slick-1.html">Single / Random Height / images</a></li>
<li><a href="slick-2.html">Single / Screen Height / BGs</a></li>
<li><a href="slick-3.html">Multiple Sliders / images</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">BX Slider <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="bx-1.html">Single / Random Height / images</a></li>
<li><a href="bx-2.html">Single / Screen Height / BGs</a></li>
<li><a href="bx-3.html">Vertical Slider / images</a></li>
<li><a href="bx-4.html">Multiple Sliders / images</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Concepts <span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="active"><a href="full-width-bg.html">Full Width BG</a></li>
<li><a href="siblings-class.html">Class Toggle, Siblings, Childs</a></li>
<li><a href="cloning.html">Cloning</a></li>
<li><a href="show-li.html">Show Hide lis</a></li>
<li><a href="Sticky-header-scroll.html">Sticky Header After Scroll</a></li>
<li><a href="switch-sides.html">Sides Switch</a></li>
<li><a href="equal-height-columns.html">Equal Height Columns</a></li>
<li><a href="masonary.html">Masonary Grid</a></li>
<li><a href="parallax-1.html">Parallax 1</a></li>
<li><a href="parallax-2.html">Parallax 2</a></li>
<li><a href="parallax-3.html">Parallax 3</a></li>
<li><a href="col-shuffle.html">Columns Shuffle</a></li>
<li><a href="bg-slider.html">Background Slider</a></li>
<li><a href="v1-slider.html">Vertical Slider - Gallery 1</a></li>
<li><a href="v2-slider.html">Vertical Slider - Gallery 2</a></li>
<li><a href="wow-reset.html">WOW Animation Reset</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Components <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="products-grid.html">Products Grid</a></li>
<li><a href="forms.html">Form</a></li>
<li><a href="fontawesome.html">Fontawesome</a></li>
<li><a href="txt-effects.html">Text Effects</a></li>
<li><a href="wowjs.html">WOW Animations</a></li>
<li><a href="vh.html">VH Centered Elements</a></li>
<li><a href="blog.html">Blog</a></li>
<li><a href="post.html">Post</a></li>
<li><a href="go-t0.html">Go To Links</a></li>
<li><a href="modal.html">Modal</a></li>
<li><a href="accordion.html">Accordion</a></li>
<li><a href="custom-multiple-collapse.html">Custom Multiple Collapse</a></li>
<li><a href="sliding-div.html">Sliding Div</a></li>
<li><a href="sliding-left-menu.html">Sliding Left Menu</a></li>
<li><a href="data-table.html">Data Table</a></li>
<li><a href="block-effects.html">Blockchain Threads Effect</a></li>
<li><a href="misc.html">Misc.</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container">
<h2>Full Width Responsive Background - Auto Calculation</h2>
<p>You need to know the height of the image and this css based technique makes the background image responsive and full width based on auto calculation. You do not need responsive queries for this technique.</p>
</div>
<div class="clear20"></div>
<div style="position: relative; width: 100%;">
<div class="full-bg-img"></div>
</div>
<div class="clear20"></div>
<div class="container">
<textarea class="form-control" rows="16">
.full-bg-img {
background-image: url('image path'); background-repeat: no-repeat;
/*background-size: contain;*/
background-size: cover;
width: 100%;
height: 0;
padding-top: 40.625%;
}
// formula
(img-height / img-width * width%)
// e.g.
// (650px / 1600px * 100%)
(650 / 1600 * 100)
// That would be the padding-top: 40.625%;
</textarea>
<br><br>
Or via jQuery
<br><br>
<textarea class="form-control" rows="16">
<script>
$( document ).ready(function() {
var main = $('.full-bg-img'),
imgwidth = 1600,
imgHeight = 550,
imgRatio = imgHeight/imgwidth,
mHeight = main.height();
$(window).resize(function() {
var cmWidth = main.width(),
cmRatio = mHeight/cmWidth;
if (cmRatio >= imgRatio) {
main.height(imgRatio * cmWidth);
} else {
main.height('550px');
}
}).resize();
});
</script>
</textarea>
<div class="clear20"></div>
View source of this page for CSS or <a href="assets/downloads/full-width-bg.zip">Download Examples</a>
</div>
<div class="clear20"></div>
<footer class="footer">
<div class="container">
<p class="text-muted text-center">Copyrights ©<span id="yearJS"></span> <a href="#">SiteName</a>. All Rights Reserved.</p>
</div>
</footer>
</div><!--.pg-wrapper ends-->
<script src="assets/scripts/jquery.min.js"></script>
<script src="assets/scripts/bootstrap.min.js"></script>
<script src="assets/scripts/wow.min.js"></script>
<script src="assets/scripts/jquery.easing.js"></script>
<script src="assets/scripts/jquery.flexslider-min.js"></script>
<script src="assets/scripts/owl.carousel.min.js"></script>
<script src="assets/scripts/custom.js"></script>
</body>
</html>