Yello,
Have been trying to figure this problem out for a while, asked a friend, a developer collegue.. No succes. Maybe one of you knows the answer?
I use an SVG image as background for my header:
CSS:
header {
height:200px;
width:100%;
background-image: url("../img/header.svg");
background-repeat: no-repeat;
background-position:0% 100%;
background-size: 100%;
}
HTML:
<header id="header"></header>
In every browser it displays perfectly but in IE(11) there is a space between the header and content on small screen sizes, the gap differs. I use Bootstraps responsive classes.
Related
I've been fiddling with my background image in CSS for a couple hours now and have tried searching through articles to find a solution but still have nothing. I'm trying to make my background image fit the screen no matter what the browser size.
At first I was using this CSS code which seemed to be working:
body {
background-image: url(images/background.jpg);
background-repeat: no-repeat;
background-size: cover;
}
But then when I re-sized the browser this happened: http://prntscr.com/j1d4kv
I then went and found another solution that said I should put the background image in the html tag, which i tried:
html {
background-image: url(images/background.jpg);
background-repeat: no-repeat;
}
This fixed the issue of the background image not fitting to the bottom when the browser size changed, but then I had this issue when I was full screened: http://prntscr.com/j1d742 It left a gap on the right side!
Most likely your body doesn't reach the full height of the browser window, if it doesn't have much content. Add this to correct that:
html, body {
height: 100%;
}
You want to add,
background-attachment: fixed;
Here's an example: https://embed.plnkr.co/3Y7O1TQa8ssPQKVq0tCW/
I have created this page and it is working fine, I'm having issue regarding the resizing, when I do resize the browser my page cropped and couldn't scroll to reach it. This is my HTML Code
<body id="page-top">
<style type="text/css">
#media (min-width:1500px) {
.new_bg {
background-image: url(img/bg2000.png);
background-size: cover;
background-repeat: no-repeat;
min-height: 50%;
}
}
in my CSS code:
html,body {
width: 100%;
height: 100%;}
Apologize if I didn't catch the needed portion of code, you may refer for the page to try, thanks.
UPDATE
]2
In you page CSS,
#media only screen and (orientation:portrait){
header{
display:none;
}
}
This is causing your page to go invisible when you resize your window. When you start resizing your window, at some width and height, the orientation is becoming as portrait and whole page is set to display:none.
Based on your question, I feel like, you don't need that style, as your query was like you are unable to find the content on resize.
Update
Your .header-content style is having -webkit-transform:TranslateY() and transform:translateY().
This is making your content to move up and making your page start position outside the browser view. Please remove these two.
Your header-content is having padding values, making your main content to move some pixels to the right. This is causing overflow. Please remove this as well.
#media (max-width:1500px) {
.new_bg {
background-image: url(img/bg2000.png);
background-size: cover;
background-repeat: no-repeat;
min-height: 50%;
}
}
change min width to max width try thiss...
I have been trying to fix this issue for days. I see a lot questions about it, but none of the solutions seem to be working for me.
I have a website that has a Bootstrap 3 front end. I want a sticky bottom footer and I'm using Bootstrap's navbar navbar-fixed-bottom styles to achieve this. It is working, but the problem is that the content will overlap with the footer when there is not enough room. I want to be able to scroll the content with the footer and header fixed and I don't want the footer to scroll with the content.
Here is the site. You can resize the height of your browser to see what I'm talking about.
Any help would be appreciated!
Icemanind, What I did here to help your issue was this.
I added height to the body.
I set the background image not using the bodytag and fixed it.
This way it now scrolls and the menu and footer stays fixed.
I also made the background image no repeat.
Is this what you were wanting.
Here is the Fiddle.
The css link to your custom css didn't want to play ball in the fiddle, but in a mock up works fine.
<style>
body{
height:2000px;
}
.bg-image {
position: fixed;
width: 100%;
height:100vh;
background: url('http://upload.wikimedia.org/wikipedia/commons/d/d3/Albert_Einstein_Head.jpg') no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
z-index: -100;
}
</style>
Updated.
Made a change to the Fiddle, I have added a transparent area to act as some content that is 2000px height.
I have added some margin to the bottom of this content.
Have a look now and see if that is what you are after here.
Here is a full size Fiddle.
I'm having trouble getting my website to display properly on mobile devices
Here's the code I used in my CSS, and this is what I want it to do on mobile devices too:
html {
background-image: url(/wp-content/themes/Newstyle/images/bg.jpg), url(/wp-content/themes/Newstyle/images/bg-repeat.jpg);
background-attachment: scroll, scroll;
background-color: #000;
background-repeat: no-repeat, repeat-y;
background-position: center top, center top;
}
html, body {
width:100%;
height:100%;
}
I have no idea what I've done wrong, I've tried a couple of fixes and I haven't been able to make it work. Can someone help? Links below.
My website - http://renoized.com
You could try either:
Background size: cover;
or
Use an image instead of a background, using absolute positioning and a z-index value of -999. Since iOS doesn't support background images with 100% width.
The method I used to fix the problem is this, regardless of how elegant or inelegant it is, I'm just glad it works.
All I had to do was copy the css from here:
html {
background-image: url(/wp-content/themes/Newstyle/images/bg.jpg), url(/wp-content/themes/Newstyle/images/bg-repeat.jpg);
background-attachment: scroll, scroll;
background-color: #000;
background-repeat: no-repeat, repeat-y;
background-position: center top, center top;
}
to my content container tag, which in my case is #page.
What this does is give the content its own background in the correct place. It also fixed a problem I had on .desktops where the background would move if your device width is smaller than the content <div>
So I am trying to do 2 things that work well on their own, but I'm having trouble integrating them together. First off, here's a link to the site: http://ericbrockmanwebsites.com/dev4
Create a fullscreen background image using
html {
min-height:100%;
background-size: cover;
background-image: url(images/bg.jpg);
background-repeat: no-repeat;
background-position: center bottom;
}
create a footer that stays at the bottom of the page, even when there's no content, which normally would require something like this:
html {
height:100%;
}
body {
height:100%;
}
.container {
min-height:100%;
}
#footer {
clear:both;
position:relative;
}
The problem is that in order for the footer to stay at the bottom the height of the html / body needs to be defined at 100%, but unless I define them using the min-height value, the background image just covers the screen as it loads. Meaning that if / when there's a need to scroll down, the background image only goes down to where the bottom of the screen was on load.
I've played around with this for a few hours, but can't seem to find a resolve. Am I missing something obvious?
Firstly, height and min-height aren't mutually exclusive. There's no reason you can't use both. As for the background scrolling when the page is longer than the available space, have you tried background-attachment: fixed?