Fixed heading hiding body elements in fluid layout - html

I am working on a fluid layout (using all percentages and no pixels) and have a fixed heading (#heading) at the top of the page. I want all elements of the rest of the site to start at the bottom of the heading and not disappear under it as the user scrolls down.
I researched this problem, but the only solution I could find was to add padding to the top of the site's main content that is equal to the height of the heading. This solution was, to my knowledge, mostly applicable to pixels because they won't behave differently in different browser window sizes or resolutions.
I tried this, but the problem is that because I'm using percentages and not pixels, the solution doesn't work when the browser window is made smaller. When I shrink the browser window, the top of the main content still disappears under the heading. I'd be grateful for any pointers.
This is the browser window at normal size:
image1
This is the browser window decreased in size:
image2
HTML:
<div id="wrap">
<div id="heading">
<div id="name">
<img src="logo.svg" width=100%>
</div>
<div id="navbar">
HOME PORTFOLIO ABOUTCONTACT RESUME
</div>
</div>
<div id="site_content">
<div id="side_panel_portfolio">
Illustration<br>
Graphic Design <br>
Web Design
</div>
<div class="divider">
</div>
<div id="mygallery">
<!--(the images)-->
</div>
</div> <!--End of #site_content-->
</div> <!--End of #wrap-->
CSS:
body {height:100%;
font-family: 'Helvetica', sans-serif;
font-weight:lighter;
font-size:1.3vmax;}
#heading{height:14%;
width:100%;
font-family: 'Raleway', sans-serif;
font-weight:300;
background-color:#ffffff;
top:0;
padding-top:0;
padding-left:0;
Padding-right:0;
position:fixed;
z-index:100;}
#site_content{padding-top:6.7%;
z-index:99;
height:100%;}
#side_panel_portfolio{float:left;
padding-left:3%;
position:fixed;}
#mygallery{float:right;
width:79%;
padding-right:%;
padding-left:3%;}
#portfolio_start{padding-left:18%;}
.divider{position:fixed;
left:15%;
top:14.7%;
bottom:40%;
border-left:1px solid black;}
Basically, I want #site_content to start at the bottom of #heading and #mygallery to be the only div that can scroll.
Sorry for the long question!!
*Also just want to say that I'm using another artist's work as thumbnails purely for the development process as placeholders and that site is NOT online and will not be online with those images.

Use a div for the logo image to be responsive
#logo {
display:block;
width:100%;
}
<div id="logo">
<img src="logo.svg">
</div>
also do you have all current media queries in your css?
Device Specific CSS Media Queries Collection

Related

rectangular image responsive in different screen size

I have an image which its size is 1050x700. I would place it in full screen when it is in desktop. the idea would be to place it when is in desktop version under the black bar in this way the image remain almost the same.
here it is the jsfiddle example http://jsfiddle.net/qLdp4czn/1/
in the mobile there is no problem because it fit the device display so it should back normal without placing it under the bar
here is the code:
<div class="container-fluid top-bar">
<div class="row-top">
<div id="central-block" class="text-center">
<p>Title</p>
</div>
</div>
</div>
<div class="img-background">
<img src="http://ppcdn.500px.org/75961441/84f7332982b9c76296fef33b528c7d6ddd22e5a0/5.jpg" alt="animal" class="img-responsive">
</div>
Put the image as a background-image instead and remove the img element:
.img-background {
background-image:url(http://ppcdn.500px.org/75961441/84f7332982b9c76296fef33b528c7d6ddd22e5a0/5.jpg);
background-repeat:no-repeat;
background-size:100% auto;
position:relative;
width:100%;
height:100%;
}
You might have to set the width and height of the element depending on your other CSS.

How to change header and footer to full width

I generated a default template provided by dreamweaver for HTML5. Here it is http://jsfiddle.net/9XFEB/ . I wan to change the header and footer to full width. If i give auto property the footer disappears. Help me find out what I am missing.
<body>
<div class="container">
<header>
<img src="" alt="Insert Logo Here" width="180" height="90" id="Insert_logo" style="background-color: #C6D580; display:block;" />
</header>
<div class="sidebar1">
<ul class="nav">
<li>Link one</li>
<li>Link two</li>
<li>Link three</li>
<li>Link four</li>
</ul>
<aside>
<p> The above links demonstrate a basic navigational structure using an unordered list styled with CSS. Use this as a starting point and modify the properties to produce your own unique look. If you require flyout menus, create your own using a Spry menu, a menu widget from Adobe's Exchange or a variety of other javascript or CSS solutions.</p>
<p>If you would like the navigation along the top, simply move the ul to the top of the page and recreate the styling.</p>
</aside>
<!-- end .sidebar1 --></div>
<article class="content">
<h1>Instructions</h1>
<section>
<h2>How to use this document</h2>
<p>Be aware that the CSS for these layouts is heavily commented. If you do most of your work in Design view, have a peek at the code to get tips on working with the CSS for the fixed layouts. You can remove these comments before you launch your site. To learn more about the techniques used in these CSS Layouts, read this article at Adobe's Developer Center - http://www.adobe.com/go/adc_css_layouts.</p>
</section>
<section>
<h2>Clearing Method</h2>
<p>Because all the columns are floated, this layout uses a clear:both declaration in the footer rule. This clearing technique forces the .container to understand where the columns end in order to show any borders or background colors you place on the .container. If your design requires you to remove the footer from the .container, you'll need to use a different clearing method. The most reliable will be to add a <br class="clearfloat" /> or <div class="clearfloat"></div> after your final floated column (but before the .container closes). This will have the same clearing effect. </p>
</section>
<section>
<h2>Logo Replacement</h2>
<p>An image placeholder was used in this layout in the header where you'll likely want to place a logo. It is recommended that you remove the placeholder and replace it with your own linked logo. </p>
<p> Be aware that if you use the Property inspector to navigate to your logo image using the SRC field (instead of removing and replacing the placeholder), you should remove the inline background and display properties. These inline styles are only used to make the logo placeholder show up in browsers for demonstration purposes. </p>
<p>To remove the inline styles, make sure your CSS Styles panel is set to Current. Select the image, and in the Properties pane of the CSS Styles panel, right click and delete the display and background properties. (Of course, you can always go directly into the code and delete the inline styles from the image or placeholder there.)</p>
</section>
<!-- end .content --></article>
<aside>
<h4>Backgrounds</h4>
<p>By nature, the background color on any block element will only show for the length of the content. If you'd like a dividing line instead of a color, place a border on the side of the .content block (but only if it will always contain more content).</p>
</aside>
<footer>
<p>This footer contains the declaration position:relative; to give Internet Explorer 6 hasLayout for the footer and cause it to clear correctly. If you're not required to support IE6, you may remove it.</p>
<address>
Address Content
</address>
</footer>
<!-- end .container --></div>
</body>
You can simply add a css style for your header and footer like this:
header {
width:100%;
height:20%; //your desired height
position:absolute;
top:0;
left:0;
background-color:blue;
}
footer{
width:100%;
height:20%; //your desired height
position:absolute;
bottom:0;
left:0;
background-color:blue;
}
SEE THIS DEMO
Another way to do this is to separate the header, the footer, and the body into three different divs:
<html>
<head></head>
<body>
<div id="body">
<div id="header">your header content</div>
<div id="bodycontainer">your body content</div>
<div id="footer">your footer content</div>
</div>
</body>
</html>
To display the header and the footer using the full width of the page, use this CSS:
#body
{
width:100%;
height:100%; // the desired height
position:absolute;
top:0;
left:0;
}
#header
{
width:100%;
height:20%; // the desired height
position:absolute;
top:0;
left:0;
background-color:blue;
}
#footer
{
width:100%;
height:20%; // the desired height
position:absolute;
bottom:0;
left:0;
background-color:blue;
}
The header will be at the top of your page and the footer at its bottom. Both use the entire screen width.
Check this fiddle:
Simple Demo
Try giving footer and header outside the main div.Which is ur <div class="container">
Check this
http://jsfiddle.net/9XFEB/2/

How to overlap sidebar on top of nav-bar

Sorry, I couldn't post images without a higher reputation, so I linked them below:
PSD:
HTML:
Okay, the PSD screenshot is of what I want the alignment to do.
And the HTML screenshot is it's current form.
As you can tell, the sidebar is currently below the orange bar (nav) and the grey bar (banner). I know there is a way to make its position absolute and overlay it on top, but seeing that this is built on a responsive grid, I think that would ruin it.
Does anyone know of anyway to overlap the sidebar like it is shown in the psd without ruining the responsiveness?
I'm open to any and all suggestions.
Thanks!
Code:
<div class="container">
<div class="row">
<header> content </header>
</div>
</div>
<nav> content </nav>
<div class="container">
<div class="row">
<div class="col-sm-9">
<section>
<!-- Services Section Content -->
</section>
<services>
<!-- Clients Section Content -->
</section>
<section>
</div>
<div class="col-sm-3">
<!-- Sidebar -->
</div>
Using position:absolute would not ruin your responsive layout if you edit your media queries to compensate.
Alternately, try a negative margin on the sidebar element and set the z-index to be higher than the top bar element. Example:
header {
width:100%;
height:100px;
background:#ccc;
z-index:100;
}
.col-sm-9 {
width:200px;
height:500px;
margin:-50px 0 0 0;
background:#000;
z-index:200;
}
Have a fiddle: http://jsfiddle.net/68ANR/
It will perfectly works.Try it because position:absolute give the position to the main div or the parent div.
.col-sm-9 {
position:absolute;
left:/*give here from left*/px;
top:/*give here from top*/px;
width:200px;
height:500px;
background:#000;
z-index:200;
}
Hope the answer !

Converting to responsive web design

I just finished my first page for a personal portfolio site. I am just a beginner when it comes to web development. I have set the width of my site to 1600 px, the same width of my background image.
What I wanted to do now is to convert the page to a responsive design. My only problem is that when I changed the width of the page to 100%, the position of my banner div is shifted to the left, instead of being in center.
here's a snippet of my code.
<body>
<div id="banner">
<div class="container_12">
<div class="grid_7 prefix_5" id="navbar">
<ul>
<li>Home</li>
<li>Portfolio</li>
<li>Blog</li>
<li>Contact</li>
</ul>
</div>
<div class="grid_10" id="bannertext">
<h1>Hello!</h1>
<div class="clear"></div>
<p>Hi, I am Gelo Lopez, an emerging digital marketing and PR Professional. I create stories for brands. I am the social media primmadonna</>
<p id="bannerbutton"><img src="Assets/Images/bannerbutton.png" width="171" height="44" alt="Gelo Lopez Portfolio" /></p>
</div>
</div>
</div><!--end of banner-->
CSS:
body {
width: 100%;
color: #5a5959;
font-size: 18px;
font-family: "Lao UI";
}
/* sections*/
#banner {
background-image: url(../Images/Banner-background.png);
height:660px;
color: #fff;
font-size: 24px;
}
I am also using a 960 gs template for 12 columns. I decided to put the container_12 div under the id=banner in order to place the content in center of the page.
I hope somebody could help me
I think what you mean is that the background image is being cut off to the right, rather than the banner div being 'shifted to the right'. The <div> as a block level element will fit it's parent, in this case it's the body which is set to 100% width.
If you're happy using CSS3, try adding background-size: contain to #banner which will scale your background image to the content area.
More info here: http://www.w3schools.com/cssref/css3_pr_background-size.asp
JSFiddle here: http://jsfiddle.net/davidpauljunior/LCFun/
You'll need to play around with background-position CSS tag. You can try putting in the extra line of CSS Code:
background-position: top left;
Also, since you're talking about it being a responsive site, you'll probably be aware that your background may not fill a screen size which you didn't design for. You'll probably need to repeat the background, or fix it... it's really according to your needs. Read up on Background repeat here: http://www.w3schools.com/cssref/pr_background-repeat.asp

have the content div be always centre aligned no matter what the window size is and regardless of whether the sidebar is there

I would like to have a specific layout but don't know how to fix it up in CSS.
here is my code:
<html>
<body>
<div id="outer" style="text-align:center;">
<div id="mainContent" style="background-color:red; width:700px; margin-left:130px;
display:inline-block;">
<p>A Lot of Text Here. Yes, A Lot of Text. Gotta Love it. More Text.</p>
</div>
<div id="rightNav" style="background-color:blue; width:130px; display:inline-block;">
<p>Some Text</p>
</div>
</div>
</body>
</html>
Now the problem is:
I want to have the content div be always centre aligned no matter what the window size is and regardless of whether the sidebar is there. The content is around 700px and the sidebar around 130px. The sidebar needs to sit to the right of the content.
Now I have managed to accomplish the above, but the tricky problem is how can I fix this so that when the window size is say 830px (700+130) that all content is visible and half of the sidebar is not cut off due to the content div being centred.
I hope I have explained this clearly enough.
Update: I have update the code to include CSS. As you can see the red section is centered, the blue to the right. This is what I want, expept when the window gets too small, I always have a minimum of a 130px gap on the left which is not what I want. (but had to put it in there to get the layout aligning right)
Something like this may help
<html>
<body style="overflow:hidden;">
<div id="mainContent" style="overflow:auto; position:absolute; top:0px; left:0px; right:130px; bottom:0px;"></div>
<div id="rightNav" style="overflow:auto; position:absolute; top:0px; width:130px; right:0px;"></div>
</body>
</html>
Edited:
#Nathan Arthur was so kind to add a nice fiddle to demonstrate the solution above.
...Demonstration of this in action: jsfiddle.net/2QQtU Try moving the middle divider to see the magic.
CSS
#outer {
position:relative;
width:830px;
margin:0 auto;
}
#content, sidebar {
float:left;
}
#content {
width:700px;
background-color:#afa;
}
#sidebar {
width:130px;
background-color:#faa;
}
That's all :)
*EDIT* just added background-colors to see the example better.
It appears what I want is not possible in a single solution. I will need to use conditional CSS to accomplish this.