Unable to overlay my navigation bar over the title page background - html

I'm teaching myself html and css whilst at uni.
I'm trying to make a one page website, and am struggling trying to later the navigation bar over the title page. As eventually, i want the navigation bar to be mainstay on each page (which will be completed later in the project via javascript).
Can anyone point me in the right direction? I've attached some of the css code below.
Cheers
#import url('https://fonts.googleapis.com/css?family=Poiret+One');
a:link {
text-decoration: none;
}
a:visited {
color: white;
}
.Nav{
border:1px solid #ccc;
border-width:1px 0;
list-style:none;
margin:0;
padding:0;
text-align:center;
font-family: Poiret One;
}
.Nav li{
display:inline;
padding: 40px;
}
.Nav a{
display:inline-block;
padding:15px;
}
.Title-Page {
background-image: url("Images/Campeche.jpg");
background-size: cover;
padding: 200px 0 260px 0;
height: 600px;
margin: 0;
}

You need a position and a z-index to make this happen. You have to have the position for z-index to work. So here are 2 examples just remember to have your pages set up the same with a position but a lower z-index this will place the page below the nav bar. Hope it helps.
If you want it fixed while the page scrolls behind it.
.Nav{
border:1px solid #ccc;
border-width:1px 0;
list-style:none;
margin:0;
padding:0;
text-align:center;
font-family: Poiret One;
position:fixed;
z-index:90
}
If You want the Nav bar to scroll with the page.
.Nav{
border:1px solid #ccc;
border-width:1px 0;
list-style:none;
margin:0;
padding:0;
text-align:center;
font-family: Poiret One;
position:absolute;
z-index:90
}
Title Page with the position set and a lower z-index.
.Title-Page {
background-image: url("Images/Campeche.jpg");
background-size: cover;
padding: 200px 0 260px 0;
height: 600px;
margin: 0;
position:absolute;
z-index:50;
}

Are you able to use z-index to achieve this? Without an example to see it's a little tough. The z-index property specifies the stack order of an element (think of bring forward or backward).
Try something like this:
.Nav {
z-index:
}
If that doesn't bring the .Nav forward, try adding this as well:
.Title-Page {
z-index: -1;
}
You may have to adjust the #'s to get the best result. The higher the #, the closer it is to you.
Note: Position could also need adjusting here. Best to put this into something like codepen if the above doesn't work and post that link.

Related

responsive div blocks don't align properly on mobile device

I have a shift calendar for a local fire department that I built using foundation5 responsive css framework. Everything works great when viewing in my browser and resizing the window.
example:
However, when I view this on an iPhone the calendar days are moved one block up.
Here is my css:
.calRow {
max-width:100%;
}
.calMonth, .calPrev, .calNext {
text-transform:uppercase;
font-weight:bold;
color:gray;
font-size:1.7em;
margin:15px 0;
text-align:center;
}
.calMonth {
text-align:center;
}
.calPrev {
text-align:left;
}
.calNext {
text-align:right;
}
.pCal ul li {
text-align:center;
height:0;
padding:0 0 14.28571%;
border-left:solid 1px gray;
border-top:solid 1px gray;
position: relative;
}
.pCal ul li:after {
content:'';
display: block;
margin-top: 100%;
}
.pCal ul li dl {
position:relative;
padding:0;
margin:0;
top:0;
height:100%;
}
.pCal ul li dl dt {
padding:0;
margin:0;
}
.pCal ul li.calHead {
font-size:0.8em;
border:none;
color:gray;
height:25px;
margin-bottom:-20px;
}
.calToday {
border-bottom:0.5em solid lightGrey;
}
.calDay {
position:relative;
padding:15%;
margin:0;
top:-100%;
}
.calLayer2, .calLayer3, .calLayer4 {
position:relative;
padding:0;
}
.calLayer2 {
top:-200%;
}
.calLayer3 {
top:-300%;
}
.calLayer4 {
top:-400%;
}
/* SHIFT HEIGHT / SIZE STYLES */
.shift2 {
height:50%
}
.shift3 {
height:33.33%
}
.shift4 {
height:25%
}
/* OVERLAY STYLES */
.calX img{
width:100%;
padding-top:2%;
}
.calCircle img{
width:100%;
padding:9% 7%;
}
.calSquare img {
width:100%;
padding:7%;
}
.pCal .calDayParts {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
.pCal .calDayOverlay {
position: absolute;
top: 0;
bottom: 0;
height: auto;
width:100%;
}
.calLayer1, .calLayer2, .calLayer3 {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
Can someone help me figure out why this is or at least suggest a way to debug it.
Thanks
EDIT 1 JS FIDDLE LINK
GO HERE for jsfiddle example - same issue is present when viewed on phone
side note, this answer has instructions on how to use iPhone over local network to connect to localhost of IIS on windows PC
It's difficult to debug without being able to inspect the site first hand. From first glance though, I would try adding a float and clear to the .calRow class, provided it is what it sounds like (the rows that make up the calendar).
.calRow {
float: left;
clear: both;
width: 100%;
}
Keep in mind by floating the calendar rows you will most likely need to also float the calendar container.
If that doesn't solve the problem it's most likely related to your absolute positioned elements not being positioned relatively to their parent element.
EDIT: I should add, if you have access to safari, an iPhone and a cord to plug the iPhone into your desktop. You can inspect the site using safari on your desktop by going to 'Develop' > 'iPhone'. More info on remote debugging here.
Okay,
so the problem was not with the css exactly. There were other styles bleeding into my styles. I placed this css inside an angular2 component and "encapsulated" the css, then it worked without the positioning error. It wraps the code in a shadow dom
I never did find out what style was bleeding into mine but the problem is now solved.

Footer gets cut off?

I'm having some issues with parts of the footer on my website getting cut of on different browsers.
On my website here http://reportalert.info/index-test.php, the twitter, rss and share icons get cut off and move around slightly when on different browsers. I've tried changing the background position and padding of each of the icons but I can't seem to get it to work across different browsers. Any suggestions on how to fix this?
Here is the code that I have for the footer:
#footer
{
clear: both;
font-family: "Droid Serif";
margin:10px 0;
padding-bottom:60px;
width:100%;
height:10px;
text-align:left;
font-size:80%;
color:#444;
}
a.ftwitter
{
background:url(http://reportalert.info/images/nra/ra-share.png/images/nra/ra-twitter.png) left no-repeat;
background-position:0 -22.5px;
padding:3px 55px;
}
a.ftwitter:hover
{
background-position:0 0;
padding:4px 55px;
}
a.frssfeed
{
background:url(http://reportalert.info/images/nra/ra-share.png/images/nra/ra-feed.png) left no-repeat;
background-position:0 -26.5px;
padding:5px 55px;
}
a.frssfeed:hover
{
background-position:0 0;
padding:6px 55px;
}
a.fshare
{
background:url(http://reportalert.info/images/nra/ra-share.png) left no-repeat;
background-position:0 -22.5px;
padding:3px 60px;
}
a.fshare:hover
{
background-position:0 0;
padding:4px 60px;
}
Thanks in advance for your help
Padding works differently in every browser, that's why your icons gets cut off in Chrome.
I would use a specific width and height instead.
Instead of padding, try using width and height. And add a display: inline-block. Here for example:
a.ftwitter
{
display: inline-block;
background:url(http://reportalert.info/images/nra/ra-share.png/images/nra/ra-twitter.png) left no-repeat;
background-position:0 -22.5px;
width: 110px;
height: 22px;
}
I think this might help. Apply this to your icons:
position:relative;
z-index:99;
The icons that get cut off are all empty a elements. Because it's an inline flow element, that means it collapses to default text height - 20 pixels in the font you use, while the Twitter icon is 22, hence causing 2 pixels to be cut off.
Set the anchors to display:inline-block, or another block layout style fitting in your layout, and the correct height which is then allowed, and it's solved.

Header CSS breaking

I'm pretty terrible at CSS/design so I'm struggling with some CSS here.
The page looks fine when loaded in a full screen browser at 1920x1080, however, as soon as you minimise or load the page on a mobile device the header content completely loses its placing but the body is fine.
Here's the CSS elements in question:
#header {
background: url(assets/header_bckg.gif) repeat-x ; height:120px;
}
#logo { display:inline-block; float:mid-left; padding:50px 0 0 570px; }
#logo { color:#FFFFFF; text-decoration:none; font-weight:bold; height:12px; font-size:20px; text-transform:uppercase;}
#login { display:inline-block; float:mid-right; padding-left:400px; padding-bottom: 7px; vertical-align:middle;}
#login{ color:#FFFFFF; text-decoration:none; font-weight:bold; height:12px; font-size:12px; text-transform:uppercase;}
#avatar { display:inline-block; position:absolute; margin-top:28px; float:mid-right; padding-left: 505px; padding-bottom: 15px; vertical-align:middle; }
#avatar_online {
background: linear-gradient(to bottom, #7BAFD6 5%, #506D92 95%) repeat scroll 0 0 transparent;
filter: none;
height: 50px;
width: 50px;
padding: 3px;
background-color: #545454;
border-radius: 3px 3px 3px 3px;
}
#avatar_offline {
background: linear-gradient(to bottom, #706C6B 5%, #4E4D4D 95%) repeat scroll 0 0 transparent;
filter: none;
height: 50px;
width: 50px;
padding: 3px;
border: 1px solid #545454;
border-radius: 3px 3px 3px 3px;
}
#avatar_playing {
background: linear-gradient(to bottom, #9BC861 5%, #789E4C 95%) repeat scroll 0 0 transparent;
filter: none;
height: 50px;
width: 50px;
padding: 3px;
border: 1px solid #545454;
border-radius: 3px 3px 3px 3px;
}
#menu {position: absolute; margin-left:550px; top:88px; color:#fff; text-align:center; margin-top:0px;}
#menu ul{ width:800px; margin:0 auto;list-style:none; padding:0; text-align:left;}
#menu ul li{display:inline}
#menu ul a { float:left; font-weight:bold; font-size:13px; text-decoration:none; color:#fff; padding:8px 10px; width:118px; text-align:center; text-transform:uppercase; background:url(assets/menu_active.gif) no-repeat bottom center; color:#232323; }
#menu ul a:hover {
color: #85B0DF;
cursor: pointer;
text-decoration: none;
}
As always, help is greatly appreciated.
Make sure your CSS and HTML are valid. As others have pointed out, there is no such thing as float:mid-left. Also, if your jsfiddle is indicative of your HTML, you're probably throwing browsers into quirksmode, because your HTML isn't structured properly (your first three tags need to be wrapped in a <head> tag, everything needs to be wrapped in an <html> tag, and the very first line should be <!DOCTYPE html>). Use the W3C's HTML validator and CSS validator to ensure your code is correct. Only then can you begin to fix other issues.
Learn what the various CSS declarations do. While your CSS may be valid, it doesn't mean it's right. This: #avatar { display:inline-block; position:absolute; margin-top:28px; float:mid-right; padding-left: 505px; padding-bottom: 15px; vertical-align:middle; } will technically validate once the float part is fixed. However, position: absolute and float are mutually exclusive -- float doesn't work when position is absolute or fixed. It will also help to learn how padding and margin affect the positioning of the element, and how they differ from one another. Finally, vertical-align doesn't work at all unless the element is a table cell, or display is set to table-cell (and the table-related set of display properties has its own quirks, so you can't necessarily just throw display: table-cell on an element and expect it to work a certain way).
Learn how elements naturally behave, so that you can work with them, instead of against them. Make sure you know how block, inline, and inline-block elements behave, and then work with them to get the layout you want, instead of throwing display: inline-block on everything and hoping for the best. The same goes for things like links (which will naturally have cursor: pointer on hover, unless you've disabled it elsewhere). Doing this will substantially clean up your CSS, making it easier to maintain. It may also clean up your HTML, as you find out what wrapper elements you truly need or can do without.
It's a little difficult to tell what the intended result should be at smaller or "mobile" widths, even with the screenshots that you included above.
It looks like there are a number of issues with your HTML, too. Be careful with things like the <font> tag (it's deprecated as of HTML4).
That said, fixing things in your CSS such as float: mid-right and float: mid-left, which are both invalid, should help a bit. Additionally, you might want to investigate CSS positioning - specifically, you'll likely want to use position: relative on your #header div.
Take a look at this slightly cleaned up version of your example - with background colors added to see where the header ends and what space the navigation occupies.
It looks like you have multiple issues but it is hard to tell without seeing your HTML as well. For starters, #menu { margin-left:550px; } is going to be part of the problem if you are trying to align on the left edge.. You should also know that float:mid-right; is not valid CSS. Check out http://www.w3schools.com/cssref/pr_class_float.asp for more information on float.
EDIT AFTER JSFIDDLE
Put your <div id='header'> inside of your <div id='main'> and change your #menu css to be:
`
#menu { margin: 0px auto; top:88px; color:#fff; text-align:center; width:800px;}
#menu ul{list-style:none; padding:0; text-align:left;}
`
Since you already have a width defined on your menu, you can use margin: 0 auto; to keep it centered based on window size. This will allow you to remove your margin-left and keep it from being pushed to the right.

Cover Effect CSS

On this site http://rushir.co/ I would like to make the Title (the slide.js) fixed, like the background is, so that when you scroll the "Who I Am" comes up to cover it. What do I do?
Also, I've somehow managed to make the Twitter and Email links fixed but I can't seem to get the "Who I Am" to cover it when it scrolls.
What do I do?
If the View Source isn't enough the code is on GitHub here https://github.com/rushir/rushir.github.io
Thanks in advance for your help!
To solve your problem you got to remove the "style = margin-top: -250px" from your nav element:
<nav style="margin-top: -250">
to
<nav>
Then put in your css file on the nav closure: position: fixed or whatever you want. Example:
nav {
position:fixed;
margin-top:0;// Or what ever value you want
width: 100%;
text-align: center;
left:0;
top:0;
}
The left: 0 and top: 0 is to make the elements don't disapear in firefox when they are fixed positioned.
This are the kind of problem that we ran when we put inline css code in our html tags. Properties that are declare in html tags cannot be overwrited later in our .css file unless we modify the .html file directly or we overwrite it using the !important hack (which is not recomendable).
e).
Extra: To center the links on the top-center of the page, replace the blocks as the same selectors with the following ones and you are done:
nav {
position:fixed;
width:100%;
left:0;
top:0
}
nav ul {
display: block;
line-height: -20;
vertical-align: center;
width:inherit;
text-align:center;
}
nav ul li {
list-style: none;
margin: 30px 30px 50px;
margin: 1.875rem 1.875rem 3.125rem;
font-family: "Lato", Arial, sans-serif;
font-size: .8125em;
font-weight: 400;
text-transform: uppercase;
display:inline-block;
}
I hope it helped :). Cheers.

How to make two different backgrounds for topbar and main body of a webpage?

I have a topbar, i.e. something like Facebook or or StackExchange or Twitter's top portion of the screen, and I want it to have a different background than the rest of the page (the stuff below/the main body). How do I accomplish this?
you can use this code :
<div id="topbar">
</div>
and you can use Position:fixed; like twitter's topbar
body{
background: green;
}
#topbar{
width:100%;
background-color:blue;
height:80px;
position:fixed;
}
Try with this
css
body { background:#252525; margin:0;padding:0;}
.headerStrip{ height:40px; width:100%; z-index:1001; background:#F00; position:absolute; position:fixed;}
Html : Put it after body tag
<div class="headerStrip"></div>
You have to place the your header_block outside your wrapper
<div id="header_block">
...... Header_block Contents
</div>
<div id="wrapper">
...... Entire Page
</div>
css
#header_block
{
position:fixed;
width:100%;
float:left;
}
This should do the work
Best way to accomplish this is to use the CSS Background property.
For example stackoverflow is using a div with an id like the following to set the background color for the gray bar up top:
<div id="custom-header"></div>
Then in their css file they are using background-color like this; note the height as well:
#custom-header {
background-color: #EEE; <------------
height: 31px;
margin-bottom: -31px;
}
This gives us the grey bar up top which passes behind the StackExchange logo.
You can see that the body is set to white via CSS and the Background (shorthand) property:
body {
background: white; <-------------
color: black;
font-family: Arial,Liberation Sans,DejaVu Sans,sans-serif;
font-size: 80%;
text-align: center;
}
You can see that the footer div is taking it a step further by using background (shorthand) and border-top for the 7 pixel solid black line:
#footer {
color: #444;
background: #777; <------------
border-top: 7px solid black; <------------
clear: both;
padding: 15px;
margin-top: 30px;
}
This is a few years old now though, you might find value in running through some tutorials like this one from Net Tuts.