sorry to post this cause I know the answer is probably super simple, but I have a div with a background image that is being cut off for some reason and i cant figure out, why?
I tried the make the div size bigger with height and width properties, I tried moving the divs around and I also tried the line-height property and I got nothing.
I have been working on this for while so I'm going to work on something else in the meantime I was hoping someone could look over it and help, possibly point me in the right direction.
THANKS!
Here is the HTML:
<nav>
<ul id="navUl">
<li class="navLinks"><a class="taimurknaziri" href="#top"><strong>TAIMUR K NAZIRI</strong></a></li>
<li class="navLinks">
<a class="navLinks" href="#projects">Projects</a>
<!-- START SUB-MENU FOR PROJECTS -->
<ul class="fallback">
<li class="navLinks">Websites</li>
<li class="navLinks">API's</li>
<li class="navLinks">Games</li>
</ul>
<!-- END SUB-MENU FOR PROJECTS -->
</li>
<li class="navLinks"><a class="navLinks" href="#about">About</a></li>
<li class="navLinks"><a class="navLinks" href="#contact">Contact</a></li>
<li class="navLinks"><a class="navLinks" href="#contact">Blog</a></li>
</ul>
</nav>
<br>
<!-- BACKGROUND -->
<div id="backgroundContainer"><br>
<div id="titleContainer">
<img id="tkn" src ="images/tkn.png">
</div>
</div>
Herre is the CSS:
body,html {
border:0;
margin:0;
padding:0;
height: 100%;
}
/* BEGIN HOME PAGE STYLING */
/* NAVIGATION BAR */
nav {
background:#ffffff;
position: fixed;
float:left;
width: 100%;
opacity: 0.8;
}
nav ul {
text-align:center;
}
nav ul li {
float:left;
display:inline;
}
nav ul li:hover {
color:#000000;
}
nav ul li a {
font-size: 11pt;
font-family: Impact;
text-decoration: none;
display:block;
padding:15px 30px;
color:#6f6f6f;
}
nav ul li ul {
position: absolute;
width:110px;
background:#ffffff;
}
nav ul li ul li {
width:110px;
}
nav ul li ul li a {
display:block;
padding:15px 10px;
color:#6f6f6f;
}
li:hover a {
color:#000000;
}
nav ul li ul.fallback {
display:none;
}
li:hover ul.fallback {
display:block;
color:#000000;
}
#navLinksContainer {
display: inline-block;
margin-top: 40px;
margin-right: ;
margin-bottom: ;
margin-left: 25px;
}
/* BEGIN BACKGROUND STYLING */
#backgroundContainer {
line-height: 40px;
background-image: url("images/nyc_bg.png");
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
background-size: 100%;
max-height: 100%;
margin-top: 50px;
}
/* TITLE THAT IS FIRST LOADED ON THE PAGE */
#titleContainer {
display: inline-block;
}
#tkn {
margin-left: 350px;
margin-top: 100px;
}
Change:
max-height: 100%;
background-size: 100%;
to:
height: 100%
background-size: cover; /* or background-size: 100% 100%; */
for #backgroundContainer.
http://jsfiddle.net/hr9G9/
There are two issues you're facing here. Both background-size and max-height are using percentages in terms of their parent div. Background-size also accepts two values - the first being width, and the second being height. If the second height isn't set, it will default to auto, which isn't what you're looking for. Setting both background-size values to 100% while changing the max-height to height solves all of your problems.
Related
Need help adding social media icons on the left side of the top bar on our website using html. I added this top bar using html so i wouldn't mind adding a new code with the left aligned social media icons, i have the photos so just need the code. Also, trying to add menu separators for each item and i am not sure how to do that either. Website: http://www.stephensengineering.com/stephens33/
#navbar ul {
margin: 0;
padding: 10px;
list-style-type: none;
text-align: right;
background-color: #000;
}
#navbar ul li {
display: inline;
}
#navbar ul li a {
text-decoration: none;
padding: .2em 1em;
color: #fff;
background-color: #000;
}
#navbar ul li a:hover {
color: #000;
background-color: #fff;
}
#navbar{
position: fixed;
z-index: 100000; /*To bring the navbar to the top of the stacking context*/
width: 100%;
}
nav.stricky-fixed.fadeInDown.animated{
top:40px; /*Since this element is already set as relative in the original code,
the top property places the slideIn menu 40px (height of black nav menu)
from the top of the page.*/
}
<div id="navbar">
<ul>
<li style="float:left"><a class="active" href="about">facebook</a></li>
<li style="float:left"><a class="active" href="#about">twitter</a></li>
<li style="float:left"><a class="active" href="#about">linkedin</a></li>
<li>project#stephensengineering.com</li>
<li>888-300-0642</li>
<li>Stephens University</li>
<li>Submit Assignment</li>
</ul>
</div>
Here's my solution. I added a few lines of code at bottom of the css file. In html file i added img tag inside the respective tags. Hope it will help you.
#navbar ul {
margin: 0;
padding: 10px;
list-style-type: none;
text-align: right;
background-color: #000;
}
#navbar ul li {
display: inline;
}
#navbar ul li a {
text-decoration: none;
padding: .2em 1em;
color: #fff;
background-color: #000;
}
#navbar ul li a:hover {
color: #000;
background-color: #fff;
}
#navbar{
position: fixed;
z-index: 100000; /*To bring the navbar to the top of the stacking context*/
width: 100%;
}
nav.stricky-fixed.fadeInDown.animated{
top:40px; /*Since this element is already set as relative in the original code,
the top property places the slideIn menu 40px (height of black nav menu)
from the top of the page.*/
}
.social-icon-wrapper:hover {
background-color: transparent !important;
}
.social-icon {
width: 20px;
vertical-align: top;
}
<div id="navbar">
<ul>
<li style="float:left"><a class="social-icon-wrapper" href="#about"><img class="social-icon" src="https://i.imgur.com/tonPA8V.png"></a></li>
<li style="float:left"><a class="social-icon-wrapper" href="#about"><img class="social-icon" src="https://i.imgur.com/fEvitJl.png"></a></li>
<li style="float:left"><a class="social-icon-wrapper" href="#about"><img class="social-icon" src="https://i.imgur.com/UiwMSrt.png"></a></li>
<li>project#stephensengineering.com</li>
<li>888-300-0642</li>
<li>Stephens University</li>
<li>Submit Assignment</li>
</ul>
</div>
This is a simple dropdown menu. It's a free template that uses webkit (only learning about what this is). I'm not very good with CSS and I can change so that the dropdown menu will not push the other content down the page, but this creates other problems.
The other problems being that the background of the dropdown menu is no longer red, but transparent and the transition doesn't work.
Additionally, even with a transparent background, when I hover over the dropdown menu, I cannot hover over the entire list without the menu collapsing. For example, in the list below, there are 4 items, Basic, Basic Plus, Ultra, and Ultra Plus. When I've set the ul to position:relative the menu no longer pushes the rest of the content down the page, but when I try to hover over Ultra, the menu goes away.
Here is where I'm developing it:
http://www.oklahomastepparentadoption.com/truck-web/index.php
I really like how the transition works on the entire drop down menu (slide down from the top).
This is the CSS code (HTML below)
.top-nav{
float: right;
width: 70%;
}
.top-nav ul{
padding:0;
margin:0;
}
.top-nav ul li{
display: inline-block;
width: 18%;
margin-right: .4em;
float: left;
position: relative;
}
.top-nav ul li.active{
background: #bb1e10;
}
.top-nav ul li a{
color: #FFF;
font-size: 18px;
margin-right: .4em;
float: left;
padding: 1em 0em 1em 1.4em;
text-align: center;
width: 79%;
}
.top-nav ul li a i{
display: block;
margin-top: 1em;
color: #FFF;
font-size: 11px;
font-style: italic;
}
.top-nav ul ul {
display: none;
left:0;
float: left;
position: relative;
}
.top-nav ul ul li {
float:none;
width:200px;
z-index: 1;
}
.top-nav ul ul li a {
padding: 5px 5px;
}
.top-nav ul li:hover > ul {
display:block;
HTML CODE:
<div class="top-nav">
<span class="menu"><img src="images/menu.png" alt=""></span>
<ul class="nav1" style="margin-top: .5em;">
<li class="hvr-sweep-to-bottom active">Home</li>
<li class="hvr-sweep-to-bottom" style="width:22%;">Fleet Management
<ul class="level_1">
<li>Basic</li>
<li>Basic Plus</li>
<li>Ultra</li>
<li>Ultra Plus</li>
</ul>
</li>
<li class="hvr-sweep-to-bottom">Broker Agency</li>
<li class="hvr-sweep-to-bottom">Drivers</li>
<li class="hvr-sweep-to-bottom">Contact</li>
<div class="clearfix"> </div>
</ul>
Add position: absolute to the menu. Also make sure to update the top and background:
.top-nav ul ul {
display: none;
left: 0;
/* Changes below */
float: none;
position: absolute;
top: 62px;
background: #bb1e10;
}
Preview
Update
Add this to the .header:
.header {
position: relative;
z-index: 10000;
}
Fixes the last links:
Exactly as Praveen says, you need to make the nav absolutely positioned. Make sure though, the container 'header' is relative positioned, else it will fill 40% of the whole screen.
check out this fiddle to see what i mean: https://jsfiddle.net/ho2sph79/
.header {
position:relative;
}
.top-nav {
position:absolute;
width:40%;
top:0;
right:0;
}
you can try this http://callmenick.com/post/slide-down-menu-with-jquery-and-css and as i noticed, your css for the dropdown doesnt have any transition elements. try the link i provided it may help you out regarding transitions
I have to code a Website for my term paper and I really have no clue how to get my Links in the navigationbar in the middle of my box.
I already looked it up on the Internet but I didnt managed to fix it. It would be cool if someone could at least give me a hint :)
nav {
background-color: lightblue;
position: absolute;
height: 5%;
width: 100%;
top: 0%;
left: 0%;
}
nav ul {
margin: 0;
padding: 0;
}
nav ul li {
list-style: none;
}
nav ul li a {
text-decoration: none;
float: left;
display: table-cell;
padding-right: 30px;
color: black;
}
nav ul li a:hover {
<nav>
<ul>
<li>Home
</li>
<li>About
</li>
<li>Products
</li>
<li>Contact us
</li>
</ul>
</nav>
http://jsfiddle.net/y6L589f7/1
It would be really nice because I need it but I really dont get it.
Instead of specifying a height for the nav bar, you could remove the height and add padding to the links to give the bar it's height:
nav {
background-color:lightblue;
position:absolute;
width:100%;
top:0%; left:0%;
}
nav ul li a {
text-decoration:none;
float:left;
display:table-cell;
padding:15px 30px 15px 0;
color:black;
}
Updated Fiddle
I have a menu where each menu item has a background image, when hovering over a menu item it is underlined by scrolling up the corresponding background image. Now I also want to display the submenu(with text items, no background image), but the submenu text isn't diplayed , if I set the border of the submenu I can see a rectangle with no proper content. I don't see what's wrong with the code, please help me correct (and improve) it.
//html structure
<div id="menu_top">
<ul id="menu">
<li class="home">Home</li>
<li class="menu">Menu
<ul class="submenu">
<li>item1</li>
<li>item2</li>
<li>item3</li>
</ul>
</li>
<li class="contact">Contacts</li>
<li class="about">About</li>
</ul>
</div>
//css styles
#menu_top
{
margin: 0 auto;
text-align: center;
background: url(../images/nav-bg.jpg) no-repeat 0 0;
height: 150px;
width: 815px;
}
ul#menu
{
list-style: none;
margin: 0;
position: relative;
}
ul#menu li
{
background-position: left top;
background-repeat: no-repeat;
display: block;
text-indent: -9000px;
position: absolute;
outline: none;
}
/*Menu items*/
// all menu items similar to this ...
ul#menu li.menu
{
background-image: url(../images/nav-menu.png);
height: 50px;
width: 116px;
top: 30px;
left: 380px;
}
/* underline menu items*/
ul#menu li:hover
{
background-position: left bottom;
}
#menu >li ul
{
position:absolute;
left:0px;
top:50px;
width:100%;
}
#menu >li ul>li
{
list-style:none;
}
#menu >li:hover > ul
{
display:block;
}
The sub menu items are not being displayed because you have set a text-indent:-9000px for ul#menu li, which means the text indent will apply to all the li items under the ul #menu. To display the sub menu items apply the below styles to the submenu li
#menu >li ul>li
{
list-style:none;
text-indent:0;
position:relative; // this is set to remove position absolute set for ul#menu li
}
OR
#menu .submenu li{
position:relative;
text-indent:0;
}
I have the below nav menu and whenever i resize using the ctrl+right click the last item FAQ appears and dissapears..not to mention it also breaks my entire site background represented by 2 images.
whats wrong and how to make it stay the same on resizing? cheers!
html:
<div class="nav">
<ul>
<li class='active '><a href='#'><span>Home</span></a></li>
<li><a href='#'><span>about us</span></a></li>
<li><a href='#'><span>our errand ladies</span></a></li>
<li><a href='#'><span>schedule an errand</span></a></li>
<li><a href='#'><span>contact us</span></a></li>
<li><a href='#'><span>faq</span></a></li>
</ul>
</div>
css:
.nav {
width: 100%;
height: 63px;
overflow: hidden;
}
.nav ul {
margin: 0;
padding: 0;
list-style-type: none;
width: auto;
position: relative;
display: block;
height: 63px;
text-transform: uppercase;
font-size: 21px;
background: transparent url('images/nav-bg-repeat.png') repeat-x top left;
font-family: Helvetica,Arial,Verdana,sans-serif;
}
.nav li {
display: block;
float: left;
margin: 0;
padding: 0;
}
.nav li a {
display: block;
float: left;
text-decoration: none;
padding:0 30px;
height: 63px;
line-height: 63px;
vertical-align: middle;
background: transparent url('images/divider.png') no-repeat top right;
}
.nav li a:hover {
background: transparent url('images/nav-hover.png') repeat-x top right;
}
.nav li a span {
color: #000;
font-weight: bold;
}
You have overflow: hidden; set on your .nav element and no width defined.
By default, the .nav is set to 100% width, as it's a block element. It will automatically span the width of the parent it's currently sitting in.
When you resize the window down to a size that cannot fit the links, they fall outside of the .nav and are hidden from view.
You can set a fixed width to your .nav (or parent container) to prevent it from collapsing in width.
.nav {
width: 960px;
}
Or if you still want it to collapse, but still show the nav links, you can remove overflow: hidden; and the elements will appear (however, they will not be inline with each other.
for the second problem set the
body{
background-repeat:no-repeat;
}
and it disappears as overflow is hidden; set it to none
.nav{
width:1000px;
overflow:none;
..
}
the way i see is you are trying to put the list elements inline so you can try this code and modify the looks:
<ul id="navlist">
<li id="active">Home</li>
<li>Here</li>
<li>There</li>
<li>Faq</li>
<li>Contact</li>
</ul>
</div>
#navlist li
{
display: inline;
list-style-type: none;
padding-right: 20px;
}