Whenever my mouse hovers to one of the long <li> elements the other elements move to the right.
Here's the fiddle link :
.footer_links{
margin-top:60px;
}
footer .ourServices{
display: inline-block;
float:left;
margin: 0px -10px 0px 77px;
}
footer .ourServices ul li,a,h3{
text-decoration: none;
color:white;
list-style: none;
}
footer .ourServices .columns_title{
text-transform: uppercase
}
footer .ourServices .columns_title{
margin-bottom:17px;
font-size:23px;
font-family:raleway-regular;
font-weight:lighter;
}
footer .ourServices ul li, h3{
margin-bottom:8px;
font-size:12px;
}
footer .ourServices ul li{
margin-top: 10px;
}
footer ul li:hover{
font-family: 'Open Sans';
font-weight:bold;
}
<div class="footer_links">
<div class="ourServices">
<h3 class="columns_title">Connect</h3>
<ul>
<li>1234 Street Name</li>
<li>Suburb Title</li>
<li>State, Australia 400</li>
<li>Phone:(00) 000 000 000</li>
<li>fax:(00) 000 000 000</li>
<li>info#email.com</li>
</ul>
</div>
<div class="ourServices">
<h3 class="columns_title">Our Services</h3>
<ul>
<li>Cotmprehensive geriatric assessment</li>
<li>Falls, mobility problems</li>
<li>Incontinence</li>
<li>Polypharmacy</li>
<li>Osteoporosis</li>
<li>Frailty</li>
</ul>
</div>
<div class="ourServices">
<h3 class="columns_title">Explore</h3>
<ul>
<li>Our Doctors</li>
<li>Treatments</li>
<li>Appointments</li>
<li>Services</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
jsfiddle.net/#&togetherjs=kdkeI5Hnq6
It is because the width of each div is being determined by the width of its contents, and the positioning of the other div is determined by the positioning of the div beside it. The bold hover effect is causing the text within to get wider, which is causing a chain reaction in the positioning of the other elements.
To fix it, set the width of the container so that it won't resize based on its contents:
footer .ourServices {
width: 170px;
}
You Just Set width for your class like this:
footer .ourServices
{
width: 150px;
}
Related
I'm making navbar and I don't want my ul li to ever become block even after resize, I wrote this code but when i convert my browser to mobile or resize and make it smaller it becomes block any solutions ?
#intro .nav ul{
position: relative;
float:right;
list-style: none;
margin-top:15px;
}
#intro .nav ul li{
font-family: 'Baloo Tammudu 2',cursive;
font-weight: 900;
padding-right:155px;
font-size:2em;
display:inline;
}
<div id="intro">
<div class="nav">
<ul>
<li class="about">
About
</li>
<li class="shop">
shop now
</li>
<li class="feedback">
feedback
</li>
</ul>
</div>
You can use Fixed "width" in your navbar. or you can use "min-width". otherwise, it's never possible.
example:
#intro .nav{
min-width:900px;
}
I am new to this and need a little help.
Just designing a random website for some practice and I can't seem to get my topmenu on my header to move up. I've changed padding's & margins in a few places and can't seem to get it to work. Wonder if I'm missing something or if there is a better way to organize my CSS. Any help would be greatly appreciated. Thanks :)
#main {
margin-left: auto;
margin-right: auto;
width: 800px;
}
body {
margin:0;
}
#topbar {
background-color: black;
height: 80px;
width: 100%;
margin-top: 0;
margin-bottom:0;
font-family:Verdana, Arial, Helvetica, sans-serif;
}
#text {
display:block;
color: White;
float:right;
padding-right: 820px;
padding-top: 10px;
font-size:20px;
}
#topmenu {
display:block;
list-style:none;
padding:0 400px 0px 0px;
float: right;
}
#topmenu li {
display: inline;
}
#topmenu a {
position:relative;
padding:0 4px 0 4px;
font-size: 13px;
text-decoration:none;
}
#topmenu a, #topmenu a:visited, #topmenu a:active {
color:white;
}
I want the menu to move up ever so slightly.
<div id="topbar" >
<div id="text"><strong>My Template Website</strong></div>
<div id="topmenu">
<ul>
<li><a href=""/>Home</li>
<li><a href=""/>About Us</li>
<li><a href=""/>Services</li>
<li><a href=""/>Product</li>
<li><a href=""/>Contact Us</li>
</ul>
I assume you already reduced the margin-bottom of the headline and the margin-top of your topmenu to 0 and now you need a way of bringing the topmenu up a bit more without absolute positioning. What you might not know is, that it is allowed to use a negative margin on the menu to bring it up:
#topmenu {
/* ... your other styles */
margin-top: -15px;
}
Before applying this you shoud check the margin of your ul which probably has a margin by the browsers default stylesheet:
You can check this by yourself when debugging the page in the web console (all popular browsers have one; e.g. in Firefox you have to press F12).
I don't know what the rest of your site looks like and if the surrounding div#topmenu is really required. But if not, you could remove it and give the id to the ul, then remove the margin-top from your new #topmenu. The advantage of this is that you don't have to manage two different elements, which possibly was the reason for your confusion in this example.
<div id="topbar" >
<div id="text"><strong>My Template Website</strong></div> <!-- <h1> instead for semantic reasons? -->
<ul id="topmenu">
<li><a href=""/>Home</li>
<li><a href=""/>About Us</li>
<li><a href=""/>Services</li>
<li><a href=""/>Product</li>
<li><a href=""/>Contact Us</li>
</ul>
</div>
I have placed one div inside of another, but it keeps appearing below the div it is nested inside. What I want is to get the login div to appear inside the navdiv but push it over to the right of the page.
I can get it over there by adding position absolute, (which I'm also unsure about) but it then behaves in ways I don't want when I resize the page.
Please try to explain what is happening here as simply as possible. Thanks!
http://jsfiddle.net/viggie/5we2wxug/
#navdiv {
display: block;
background-color: blue;
height: 20px;
margin-bottom: 7px;
}
ul {
text-align: center;
}
#navdiv li {
background-color: red;
display :inline;
font-size: 1.3em;
padding-left: 25px;
padding-right: 25px;
vertical-align: middle;
margin-left:35px;
margin-right:35px;
margin-bottom:4px;
}
#navdiv li a:visited {
color: yellow;
}
#navdiv li:hover {
background-color: green;
}
#login {
padding-right: 10px;
padding-left: 10px;
background-color: yellow;
top: 0;
right: 0;
}
#login li {
verticle-align: middle;
}
HTML
<div id="navdiv">
<ul>
<li>Home</li>
<li>Members</li>
<li>Articles</li>
<li>Videos</li>
<li>Join</li>
</ul>
<div id="login">
<ul>
<li>Log out</li>
<li>Log in</li>
</ul>
</div>
</div>
While your #login div is technically inside of #navdiv, #navdiv has a height set which is stopping the background from extending to cover the #login as well - The #login is inside it structurally, but visually it's overflowing the #navdiv area.
So, to stop that bit, simply remove the height from #navdiv.
To align the login to the right, I'd recommend making the #login ul an inline-block that's simply aligned right. You lose the absolute andfloat issues, and it's easy to make responsive.
#login {
text-align: right;
}
#login ul {
padding-right: 10px;
padding-left: 10px;
background-color: yellow;
display: inline-block;
}
Note, I also put the background color on the ul since it's more accurate to the #login area - probably you'll want to modify the styling some yet anyways.
http://jsfiddle.net/daCrosby/5we2wxug/1/
Put this code in your css
.left_part { float:left;width:72%;}
.right_part { float:right;width:28%;}
.right_part ul { padding-left:0px;}
and add this in body part
<div id="navdiv">
<div class="left_part">
<ul>
<li>Home</li>
<li>Members</li>
<li>Articles</li>
<li>Videos</li>
<li>Join</li>
</ul>
</div>
<div class="right_part">
<ul>
<li>Log out</li>
<li>Log in</li>
</ul>
</div>
</div>
i just gave you normal idea and now i hope you can manage your own css with this way...hope it helps..
Updated
according to you...just use Float in ul and in login div as login div will not go with ul until you are not using float left or right properties..they have their own css and you have to use float for this...there can be more option but float will help you in your case if you don't want more div..
I want to align menu text at the bottom of image how to i achieve it?
Expected output:
Image Image Image Image
[menutext] [menutext][menutext] [menutext]
Actual output :
Image[menutext] Image[menutext] Image[menutext] Image[menutext]
my Css Code:
#vilaniHeader
{
margin: 0;
padding: 0;
height: 80px;
background-color: Black;
}
#vilaniHeader h1
{
padding-left: 15%;
font: Arial;
font-size: 30px;
color: #ffffff;
font-weight: bold;
float: left;
}
#vilaniHeader #menu
{
color: #ffffff;
font: Arial;
font-size: 18px;
font-weight: bold;
padding-top: 30px;
padding-left: 30%;
}
#vilaniHeader #menu ul
{
list-style: none;
margin: 0;
padding: 0;
padding-right: 300px;
padding-bottom: 300px;
}
#vilaniHeader #menu li
{
display: inline;
margin: 0 15px 0 15px;
float: none;
text-align:center;
}
#vilaniHeader #menu a
{
text-decoration: none;
color: #ffffff;
}
#vilaniHeader #menu .menuHome
{
color: red;
clear:both;
padding-top:50px;
background-image:url:("Styles/menuHome.png") ;
vertical-align:text-top;
}
and My HTML code
<div id="vilaniHeader">
<h1>
Comany name
</h1>
<div id="menu">
<ul>
<li class="menuHome"><img src="Styles/menuHome.png" />Home</li>
<li><a href="About.aspx">Car</li>
<li><a href="About.aspx">Mobile</li>
<li><a href="About.aspx">OldThings</li>
<li><a href="About.aspx">Matrimoni</li>
</ul>
</div>
</div>
I want menu text should be align at the bottom of the image plese help me to do that.
I came up with this solution building upon the answer here from tejash. My answer validates and is search engine friendly.
I prefered to use links within a div but I imagine this will work with an ul
I use a background image that does not show if CSS is disabled
I use a span set displayed as block because a div inside an a tag does not validate
I use a class to place the image but use ids if you want different pics for each link
Change the width + heights to suit your needs
HTML
<div id="nav">
<span class="image"></span><span>About Us</span>
<span class="image"></span><span>Investors</span>
</div>
CSS
#nav a {
display:block;
float: left;
width:100px;
}
.image {
display:block;
background: url("myimage.jpg") no-repeat scroll center center transparent;
height:40px;
width:100px;
}
Make the img a block element so it takes the full width / line-breaks afterwards.
#menu li { display:block; }
That’s all.
I would suggest add some wrapper on text and make image and wrapper both display:block;
You can use span tag as an wrapper for text.
HTML
<ul>
<li><a><img src="Styles/menuHome.png" /><span>Home</span></a></li>
</ul>
CSS
li img, li span
{
display:block;
}
If you want your text to overlay your image, but at the bottom, you should try to play around with the line-height property. That will cause your text to move down, so it will be in the center of it's line.
I have two solutions for you. style1 works for items with text smaller than the image. style2 works for items with text wider than the image. Easiest is to make sure that the images are always wider or smaller than the text, so that you need only one style.
CSS:
#menu {
list-style:none
}
#menu li {
float:left;
text-align:center
}
#menu .style1 img, #menu .style2 span {
overflow:hidden
}
#menu .style1 span, #menu .style2 img {
display:block
}
HTML:
<div id="vilaniHeader">
<h1>Comany name</h1>
<ul id="menu">
<li class="style1"><img src="Styles/menuHome.png" width="10" alt="" /> <span>Home</span></li>
<li class="style2"><img src="Styles/menuHome.png" width="100" alt="" /> <span>Car</span></li>
</ul>
</div>
I'm not a span-fan but it seems like you can't do it without here.
BTW, why don't you just add a br?
CSS:
#menu {
list-style:none
}
#menu li {
float:left;
text-align:center
}
HTML:
<div id="vilaniHeader">
<h1>Comany name</h1>
<ul id="menu">
<li><img src="Styles/menuHome.png" width="10" alt="" /><br />Home</li>
<li><img src="Styles/menuHome.png" width="100" alt="" /><br />Car</li>
</ul>
</div>
I guess that's the most easy and reliable solution.
You can do this way, obviously replacing the image sample I used. For the link to work, you can use a jQuery click event on LI, so it searches for the link inside the clicked LI and then opens the desired link.
http://jsfiddle.net/WcePK/
HTML
<ul>
<li class="menuHome"><img src="Styles/menuHome.png" />Home</li>
<li style="background-image: url('http://jsfiddle.net/img/logo.png')">Car</li>
<li style="background-image: url('http://jsfiddle.net/img/logo.png')">Mobile</li>
<li style="background-image: url('http://jsfiddle.net/img/logo.png')">OldThings</li>
<li style="background-image: url('http://jsfiddle.net/img/logo.png')">Matrimoni</li>
</ul>
CSS
LI {
float: left;
margin: 5px;
padding: 50px 10px 10px;
min-width: 100px;
background-repeat: no-repeat;
background-position: center 10px;
background-color: #366D93;
text-align: center;
cursor: pointer
}
Here is my code:
HTML
<div class="menu">
<ul>
<li class="active">HOME</li>
<li class="active">COMPANY</li>
<li class="active">SOLUTIONS</li>
<li class="active">SERVICES</li>
<li class="active">NEWS & EVENTS</li>
<li class="active">BLOGS</li>
<li class="active">CONTACTS</li>
</ul>
</div>
CSS
.header .menu ul { margin:33px 10px 0 0; padding:0; float:right; width:auto; height:12px; list-style:none;}
.header .menu ul li { margin:0 4px; float:left;}
It does not recognize the height feature. Why? How can I set the height of menu item?
You're missing a semicolon :-)
You can also try setting the line-height property of the li tags to change the position of the text in the element:
.line-height-li {
line-height: 30px;
}
Just increase the padding-top and padding-bottom as you want. Line height effect other. I found out it by testing it. It work for me.
.header .menu ul { margin:33px 10px 0 0; padding:0; float:right; width:auto;list-style:none;}
.header .menu ul li { margin:0 4px; float:left;}
.active{height:50px;}
ul is set to a height of 12 pixels, at least in Firefox.
Is the height set on the correct element? You're asking how to set the height of a menu item (presumably, an li) but your CSS says you're setting the height of the ul. Perhaps, moving height: 12px; from where it is to .header .menu ul li could help.
The height of the list does not necessarily change the height of the visible list items. I created a small example to show how those heights look like, if you hover on the items, you'll see the height's changing. That because of the overflow attribute of the list.
.menu ul {
margin: 10px 10px 10px 5px;
padding: 10px;
float: right;
width: auto;
height: 12px;
list-style: none;
background: cyan;
overflow: hidden;
}
.menu ul:hover {
overflow: visible;
}
.menu ul li {
margin: 4px;
padding: 4px;
float: left;
background: yellow;
}
<div class="menu">
<ul>
<li class="active">HOME</li>
<li class="active">COMPANY</li>
<li class="active">SOLUTIONS</li>
<li class="active">SERVICES</li>
<li class="active">NEWS & EVENTS</li>
<li class="active">BLOGS</li>
<li class="active">CONTACTS</li>
</ul>
</div>
Anyway, in your example, there's no div with a class "header" in your HTML, that's confusing for beginners. Your CSS rules begin with ".header".