My background image and its text are responsive to width resizing as long as the browser height is sized to the max. But when decreasing browser (such as Chrome) height the background image doesn't fit the whole window anymore. Any suggestions help!
#header {
background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url(/img/roses.jpg);
background-size: cover;
background-position: center center;
height: 100vh;
}
.name h1 {
font-family: 'Muli', sans-serif;
font-size: 500%;
font-weight: 300;
text-align: center;
padding-top: 10%;
}
.name p {
font-family: 'Play', sans-serif;
font-size: 150%;
text-align: center;
padding-top: 5%;
}
.navigation p {
display: inline;
}
.navigation {
text-align: center;
padding-top: 10%;
}
.contents:hover {
color: white;
text-decoration: none;
}
.contents {
color: whitesmoke;
text-decoration: none;
}
/* Media Queries */
#media (max-width: 33.9em) {
.name h1 {
font-size: 300%;
}
.name p {
font-size: 100%;
}
}
<section id="header">
<div class="container">
<div class="row">
<div class="col-xs-12 name">
<h1>Temple Naylor</h1>
</div>
</div>
<div class="row">
<div class="col-xs-12 name">
<p>I create Web-designs with a sense of Feng-Shui in mind; resulting for a intuitive, responsive, harmonious, experience for users across the world. <br>
NOW AVAILABLE FOR YOU</p>
</div>
</div>
<div class="row">
<div class="col-xs-12 navigation hidden-md-down">
<p><a class="contents" href="#">ABOUT</a> / </p>
<p><a class="contents" href="#">WORK</a> / </p>
<p><a class="contents" href="#">CONTACT</a> / </p>
<p><a class="contents" href="#">PHOTOGRAPHY</a></p>
</div>
</div>
</div>
</section>
Close but a little off. You want background-size: cover
body {
background: url(http://www.hd-wallpapersdownload.com/script/bulk-upload/3d-wallpaper-rose-dowload.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
DEMO
UPDATE:
I was told the OP would like to keep text from scrolling as it shrunk, so here is a version of the text in VW opposed to PX so it becomes responsive as well.
DEMO with responsive text.
When you resize the window, #header is more than 100% of the browser height due the .container inside, therefore the scrolling.
To fix it, add
#header { overflow: hidden; }
body { margin: 0; }
or get the .container out of the #header
you may want to use background-size: 100%;
updated
remove height: 100vh; from header and this should fix the problem
see fiddle
you may want to add background-position: fixed if this suits you, fiddle
see this great tut https://css-tricks.com/perfect-full-page-background-image/
Related
I have placed a background image inside a div but would like it to be an active link to another page, and also maybe light up when hovered over. Here is the HTML & the CSS, any help would be greatly appreciated! thanks...
<div class="col-sm-4 img1">Football</div>
.img1 {
background-image: url(https://....);
background-repeat: no-repeat;
background-size: cover;
EDIT: full code;
.img1 {
background-image: url(https://images.unsplash.com/photo-1472108482137-8df36ccf0d7b?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80);
background-repeat: no-repeat;
background-size: cover;
font-weight: bolder;
font-size: xx-large;
}
.img2 {
background-image: url(https://cdn.pixabay.com/photo/2015/05/28/16/37/sport-788105_960_720.jpg);
background-repeat: no-repeat;
background-size: 100%;
background-size: cover;
font-weight: bolder;
font-size: xx-large;
}
.img3 {
background-image: url(https://images.unsplash.com/photo-1528543606781-2f6e6857f318?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=701&q=80);
background-size: 80%;
background-repeat: no-repeat;
background-size: cover;
font-weight: bolder;
font-size: xx-large;
}
<!-- Containers center and horizontally pad your content -->
<div class="container-fluid">
<!-- create row inside container / row is wrapper for column-->
<div class="row">
<!-- now create 3 columns with small breakpoint -->
<div class="col-sm-4 brdcol img1"> Water Sports</div>
<div class="col-sm-4 brdcol img2">Football</div>
<div class="col-sm-4 brdcol img3">Hiking</div>
<!-- columns centred in page with parent container -->
</div>
</div>
All you need to do to have a clickable image - is to wrap your div element(the one with background image) with anchor tag, like this:
<div class="col-sm-4 img1">Football</div>
You need a single anchor tag with some CSS.
<a class="photo" href="website.net/link"></a>
CSS
.photo {
background-image: url('http://www.thinksnaps.com/wp-content/uploads/2014/07/images-background.jpg');
background-size: 300px;
background-repeat: no-repeat;
background-position: center;
border-radius: 50%;
background-clip: border-box;
transition: background-size 0.2s;
transition-timing-function: cubic-bezier(.07,1.41,.82,1.41);
display: block;
width: 190px;
height: 190px;
text-decoration: none;
cursor: pointer;
overflow: hidden;
text-indent: 100%;
white-space:nowrap;
}
.photo:hover {
background-size: 500px;
}
Here's my page:
The problem is, my Jumbotron placed on the upper side of the page. I want to move it to the center (a little down below). I tried overriding margin and padding but it still didn't work. How would I do that?
Here's my HTML
<div class="col-md-6">
<div class="welcome-page-eat">
<div class="jumbotron">
<h2>
Hello, world!
</h2>
<p>
This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.
</p>
<p>
<a class="btn btn-primary btn-large" href="#">Learn more</a>
</p>
</div>
</div>
</div>
And here's my CSS:
.welcome-page-eat {
background: url(../images/front_page/eat.jpg) no-repeat right 0;
margin-right: -15px;
margin-left: -15px;
padding-bottom: 62.5%;
background-position: 50% 50%;
background-repeat: no-repeat;
background-size: cover;
}
.welcome-page-cook {
background: url(../images/front_page/cook.jpg) no-repeat right 0;
margin-right: -15px;
margin-left: -15px;
padding-bottom: 62.5%;
background-position: 50% 50%;
background-repeat: no-repeat;
background-size: cover;
}
.jumbotron {
background-color: transparent;
color: white;
}
Try using:
.jumbotron {
background-color: transparent;
color: white;
margin: auto;
width: 90%;
}
Maybe this article can help you: W3CSchools | CSS Margin
Been searching for hours now. I want flexslider for a kind of banner rotator on a page. I managed to get a fixed height for the images. But the width of the images get stretched to the browsers borders left and right. I believe what i want is some kine of "overflow: hidden". If browser_width > img_width: show background left and right from the image. If browser_width < img_width: Cut of parts from the image on left and right side. All ways keep the aspect ratio.
Currently the image gets stretched/shrinked horizontally.
HTML
<div class="flexslider">
<ul class="slides">
<li>
<div class="flexslider_image">
<img src="/images/alnwick-castle-92607.png" />
</div>
</li>
<li>
<div class="flexslider_image">
<img src="/images/server-90389.png" />
</div>
</li>
</ul>
</div>
CSS
.slider_container {
margin-top: -120px;
}
.flexslider {
border: none !important;
box-shadow: none;
margin:0px;
padding: 0px;
}
.slides li {
background-position: center;
-webkit-backface-visibility: hidden;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.flexslider_image {
}
.flexslider_image img {
height: 500px;
}
After searching for some more hours i found a solution.
Do not use an img-tag for the image. Instead use a div with a background image. For details see my html and css.
Another advantage i was locking for anyway is, that one can now more easily place content on the slides.
HTML
<div class="flexslider">
<ul class="slides">
<li>
<div class="flexslider_background" style="background: url('/images/server-90389.png') no-repeat center;">
<div class="flexslider_content">
<p>
Hallo Test 2
</p>
</div>
</div>
</li>
<li>
<div class="flexslider_background" style="background: url('/images/minecraft-938604.png') no-repeat center;">
<div class="flexslider_content">
<p>
Hallo Test 3
</p>
</div>
</div>
</li>
<li>
<div class="flexslider_background" style="background: url('/images/minecraft-669310.jpg') no-repeat center;">
<div class="flexslider_content">
<p>
Hallo Test 4
</p>
</div>
</div>
</li>
</ul>
</div>
CSS
.slider_container {
margin-top: -120px;
}
.flexslider {
border: none !important;
box-shadow: none !important;
margin:0px !important;
padding: 0px !important;
margin-bottom: 10px !important;
background-color: #eee !important;
}
.slides li {
background-position: center;
-webkit-backface-visibility: hidden;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.flexslider_background {
height: 500px;
text-align: center;
}
.flexslider_content {
display: inline-block;
margin-top: 145px;
height: 350px;
width: 1000px;
border: 3px solid black;
}
.flexslider_content p {
float: left;
font-size: 2em;
}
I have a section of a website where I need a full screen background image. I used the trick from CSS Tricks - the first option. That works fine, but I have some content in that section and it is not contained. so if the height is reduced, but the width at max on a screen, the content of that section overflows. Is there any smart way of containing that content so that it reduces by height as well?
This is the CSS I'm using.
background: url('https://dl.dropboxusercontent.com/u/72385383/services-header-bg.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
See example fiddle.
The fiddle doesn't show the result properly, here is a screenshot of what I mean. I need it to work as in the fiddle where it's contained (so that the background image expands in height even more than the current height of the browser, but in both Chrome and Mozilla, it runs out. See example full screen and reduced.
Please help
EDIT
Here is the entire HTML
<div id="services-header">
<div class="container">
<div class="row">
<div class="col-xs-12" style="height: 100%;">
<h1>
The Creativity of the West meet <br>
the Technical Skill & Expertise of the East
</h1>
<p>
Our extraordinary team brings years of technology related experience to the table to ensure <br>
that you receive an amazing product at an unbelievable price. <br><br>
</p>
<img src="https://dl.dropboxusercontent.com/u/72385383/platforms.png" alt="Platforms"> <br><br><br><br><br><br>
<img src="https://dl.dropboxusercontent.com/u/72385383/iphone6.png" alt="iPhone APPR">
</div>
</div>
</div>
</div>
<div id="services-content">
<div class="container">
<div class="row">
<div class="col-xs-12">
<h1>What we can do for you</h1>
</div>
</div>
<div class="row service-row">
<img src="https://dl.dropboxusercontent.com/u/72385383/s-creative.jpg" alt="">
<p class="service">
Mobile Application <br>
Design & Development
</p>
<p class="desc">(iOS — Android — Windows)</p>
</div>
</div>
</div>
And here is the CSS:
body {
margin: 0;
padding: 0;
}
img {max-width: 100%;}
#services-header{
background: url('https://dl.dropboxusercontent.com/u/72385383/services-header-bg.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
min-height: 100%;
text-align: center;
font-weight: 300;
color: #ffffff;
}
#services-header h1 {
font-size: 56px;
padding-top: 60px;
font-weight: 300;
line-height: 120%;
margin-bottom: .3em;
}
#services-header p {
font-size: 24px;
}
#services-content h1 {
font-size: 56px;
font-weight: 300;
text-align: center;
}
#services-content img {
display: block;
margin: 10px auto;
}
#services-content p.service {
font-weight: 600;
text-align: center;
}
#services-content p.service a{
font-weight: 600;
text-align: center;
color: #f93434;
cursor: pointer;
}
#services-content p.desc {
font-weight: 300;
text-align: center;
}
.service-row {
margin-bottom: 50px;
}
footer.services-page {
background: #000000;
padding: 20px 40px;
color: #ffffff;
font-weight: 300;
}
span.copyright {
}
span.footer-contact {
float: right;
}
span.footer-contact a {
margin-right: 30px;
color: #ffffff;
cursor: pointer;
}
The problem was that Mozilla needed a body {height:100%;} definition.
If you're trying to accomplish the same as the CSS-Tricks example you have to do the same
html{
background: url('https://dl.dropboxusercontent.com/u/72385383/services-header-bg.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
I'm trying to create a responsiveness sticky footer but without any success. I have followed every guide and every common best practices. Here it is my example: example
In the example I would put the footer at the bottom of the page.In addition I would use an image as background of the entire page
.blur {
height: 100%;
background: url('image.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
Do you have any idea?
keep your HTML just as is, and change your CSS to this (obviously you'll change it later to your needs, I just added styling for visualization purposes):
html, body {
background-color: #FFF;
font-family:'Raleway', 'Open Sans', sans-serif;
font-weight: 400;
}
body {
color: #333;
background:url('http://2.bp.blogspot.com/-OSVC5PTEAKU/TZNnUHaoJZI/AAAAAAAAApo/WcP3qSUPAoo/s1600/monta%2525C3%2525B1as%252520verdes%255B1%255D.jpg') no-repeat 50%;
background-size:cover;
min-height: 100vh;
padding-bottom:80px /* footer height + 20 px for spacing, but adjust as you like */;
}
a {
color: #eee;
}
a:hover, a:focus {
text-decoration: none;
color: #dedede;
}
/* Langind Page */
.inner {
margin-top: 20px;
}
.btn-facebook-inner {
margin-top: 80px;
padding: 30px;
}
.btn-facebook {
width: 300px;
border-radius: 4px;
background-color: #3B5998;
-webkit-box-shadow: 0 2px 4px rgba(0, 0, 0, .5);
box-shadow: 0 2px 4px rgba(0, 0, 0, .5);
font-family:'Lucida Grande', sans-serif;
}
.btn-facebook:hover, .btn-facebook:focus {
color: #dfe3ee;
text-decoration: none;
}
footer {
position:fixed;
bottom:0;
left:0;
width:100%;
height:60px;
background:#fc0;
}
footer .social-icons > ul > li {
padding-right: 12px;
}
See fiddle here
This will make the bottom to be fixed, so if you have a lot of content, the footer will overlap the content. If you don't want this behavior, change fixed to absolute
Just a comment I have seen on your code and see as a recurrent error around here: while it's common to target html and body together, they're NOT the same thing and not all styles applies to both
I looked at this and went a different way. If you are inherently setting a "height" value for the footer, while your footer will still "respond", the background follows the styling and will only display at "n px" leaving you with the body color below.
Use the following code
HTML:
<body>
<div id="wrap">
</div>
<div id="footer">
</div>
CSS:
html,
body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto !important;
height: 100%;
/* Negative indent footer by its height */
margin: 0 auto -60px;
/* Pad bottom by footer height */
padding: 0 0 60px;
}
/* Set the fixed height of the footer here */
#footer {
height: 60px;
background-color: #f5f5f5;
}
Edit
HTML
<!-- Wrap all page content here -->
<div id="blur">
<!-- Begin page content -->
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4 inner">
<h1 class="text-center">Title</h1>
</div>
</div>
<div class="row">
<div class="col-md-4 col-md-offset-4 btn-facebook-inner">
Login with Facebook
</div>
</div>
</div>
</div>
<div id="footer">
<div class="container">
<div class="row">
<div class="col-md-3 col-md-push-9 social-icons">
<ul class="list-inline">
<li>Facebook</li>
<li>Instagram</li>
<li>Twitter</li>
</ul>
</div>
<div class="col-md-9 col-md-pull-3">
<ul class="list-inline">
<li>Privacy Policy</li>
<li>Terms of Use</li>
</ul>
</div>
</div>
</div>
</div>
CSS
html,
body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
#blur {
min-height: 100%;
height: auto !important;
height: 100%;
/* Negative indent footer by its height */
margin: 0 auto -60px;
/* Pad bottom by footer height */
padding: 0 0 60px;
}
/* Set the fixed height of the footer here */
#footer {
height: 60px;
background-color: #f5f5f5;
}