How to remove body spaces - html

I use this CSS codes for generating fixed menu bar and I am facing margin problem, I use top and left margin 0 but this problem happened. Please check following link for detail.
Please check this URL
#menu ul{
margin-top:0px;
margin-left:0;
background:#999999;
height:50px;
width:100%;
position:fixed;
border:solid green;
list-style:none;
padding:0;
}
ul {
list-style-type:none;
margin:0;
padding:0;
}
a {
display:block;
width:60px;
}
li {
display:inline;
}
li {
float:left;
}
a {
display:block;
width:60px;
}

Use a default style sheet that "reset" the style.
Like this : http://meyerweb.com/eric/tools/css/reset/

This is because of body margin, You can remove it simply:
body{
margin:0
}

Use the following code to reset the margin and padding
* {
padding: 0;
margin: 0;
}

* {
padding: 0;
margin: 0;
}

Related

li type won't display

I have the following css:
ul {
padding:0;
margin:0;
}
li {
padding:0;
margin:0;
list-style:none;
}
ul.square li {
padding-left:20px;
list-style:square;
}
and the following Html structure:
<ul class="square">
<li>blah blah blah</li>
</ul>
the list comes up with no padding and no leading square. How can I fixed this issue?
Here you go! Just use margin, instead of padding –> Demo
ul.square {
padding:0;
margin: 0; /* reset the margin */
margin-left:20px; /* then add yours */
list-style: square;
}
This only works with ol (tried it with ul and it doesn't work). Could not get the square to work with ul with any solution provided here or elsewhere. But at least this solution does add the margin/indentation. Thank you for all of the help.
In CSS:
ul {
padding:0;
margin:0;
}
li {
padding:0;
margin:0;
list-style:none;
}
ol.margin {
padding:0;
margin: 0; /* reset the margin */
margin-left:20px; /* then add yours */
}
then in the HTML doc
<ol id="margin">
<li>blah</li>
</ol>

Can't seem to center my menu

I have done this code for a bit of extra study but I can't seem to center the work and I'm not to sure if I need so much code feel like some should be removed, please help!
If some of the code needs to be taken away I understand just dont quite understand and I feel like everything I Read make me more lost and Just keep changing my code with no solution :(
#menubar{
background:#3399CC;
height:120px;
}
#menubarwrap {
margin:0 auto;
width:100%;
}
#navigationbar-main {
float:left;
padding:15px;
color:#000;
font-size:24px;
font-weight:bold;
list-style-type: none;
margin-bottom:10px;
text-align:center;
}
#navigationbar-main li {
margin-right:35px;
position:relative;
}
#navigationbar-main li a {
display:block;
color:#000;
}
#navigationbar-main li ul {
display:none;
z-index:80;
}
.nav-sec {
display:block;
font-size:12px;
font-family: lucida sans unicode;
font-weight:normal;
text-align:center;
}
HTML
<body>
<div id="menubar">
<div id="menubarwrap">
<ul id="navigationbar-main">
<li>Home<span class="nav-sec">Where We Start</span></li>
<li>Gallery<span class="nav-sec">Pure Beauty</span></li>
<li>Contact<span class="nav-sec">Come Book</span></li>
<li>Features<span class="nav-sec">Pure Luxury</span></li>
<li>Location<span class="nav-sec">Where Are We?</span></li>
<li>Rates<span class="nav-sec">Price Of Love</span></li>
</ul>
</div>
</div>
</body>
sorry I'm just fairly new to all this
I am providing with two solutions guessing its what you need:
Fiddle 1
Change
#navigationbar-main {
margin:0px auto;
/*removed float
Other styles remain same*/
}
Fiddle 2
Change
#navigationbar-main li {
display:inline-block;
/*Other styles remain same*/
}
change your ul css
#navigationbar-main {
color: #000000;
font-size: 24px;
font-weight: bold;
list-style-type: none;
margin: 0 auto 10px;
padding: 15px;
text-align: center;
width: 1000px;
}
and give flat:left to your li
If you are trying to center align the #navigationbar-main ul, do this
#navigationbar-main ul{
float:left /*remove this line*/
}
This will get you the ul to the center of the page horizontally.
And if you want to align the li items horizontally apply this:
#navigationbar-main li {
display:inline-block;
}
#navigationbar-main {
width: 100%;
}
Add this to your CSS,

CSS li list, margin from the left

I don`t understand why I have margin from the left:
CSS:
html, body {
font-family:Myriad Pro, sans-serif;
font-size:18px;
color:#000;
margin:0px;
padding:0px;
background: url('./images/background.png');
}
#container {
width:890px;
height:530px;
margin:36px auto;
}
#userList {
width:228px;
height:355px;
float:right;
border:1px solid #cccccc;
}
.users li {
list-style-type:none;
background-color: #f2f2f2;
width:100%;
height:50px;
border-bottom: 1px solid #cccccc;
}
HTML:
<div id="userList"><ul class="users"><li><img src="./pic/none.png">Piet van Meerdijk</li><li><img src="./pic/none.png">Henk v/d Wal</li></ul></div>
When I put margin-left:-40px; in the CSS code the li item will be on the left now, but then have I a margin on the right. Why?
JSfiddle: http://jsfiddle.net/8Cwcy/
The <ul> tag has an automatic padding of 40px so you will need to change that to 0px:
ul {
padding: 0px;
}
This should work across all browsers.
Fiddle: http://jsfiddle.net/8Cwcy/3/
By default a lot of HTML elements have their own CSS rules in many browsers, and <ul> tag has a padding by default. You need to set padding:0px to de <ul> tag:
ul{
padding:0px;
}
http://jsfiddle.net/8Cwcy/1/
If you want to know more about CSS reset rules follow this link.

How to give ul nav tabs width space but still float left

I have an unordered list used for navigation tabs. I want them to have space between them but I also want the beginning of the list to line up with the rest of the text to the left.
I know this is simple but I can't figure it out.
http://jsfiddle.net/29g9S/3/
<body>
<div class="page-box">
<p>I am trying to get the ul's li's to line up with the "My Blog" text and still flow with the document</p>
<h1>My Blog</h1>
<ul>
<li>test</li>
<li>test</li>
<li>test</li>
</ul>
</div>
</body>
CSS
.page-box{
position:relative;
left:50px;
}
ul{
position:relative;
left:0px;
}
ul>li{
float:left;
position:relative;
margin-left:100px;
list-style-type:none;
}
The key is killing the margin / padding on the ul:
.page-box{
position:relative;
left:50px;
}
ul{
position:relative;
margin:0;
padding:0;
}
ul>li{
display:inline-block;
position:relative;
margin:0 100px 0 0;
list-style-type:none;
}
Here is an updated jsFiddle. Notice the use of display:inline-block; instead of float:left;. Floats are a one way ticket to old webville! Embrace the wonder that is display:inline-block! :D
If i understood correctly css can be modified as follows,
http://jsfiddle.net/fTdHH/
ul{
position:relative;
left:0px;
padding:0px;
}
ul>li{
float:left;
position:relative;
/* margin-left:100px; */
margin-right:100px;
list-style-type:none;
}
Set
ul {
margin: 0;
padding: 0;
}
ul>li {
// no margin-left
margin-right: 100px;
}
http://jsfiddle.net/beautifulcoder/29g9S/8/
PlantTheldea is right about the margin/padding on the ul. If you want to keep the list items floated with margin-left, just remove the margin-left from the first list-item by using li:first-child:
.page-box {
position:relative;
left:50px;
}
ul {
margin:0;
padding:0;
position:relative;
left:0px;
}
ul>li {
float:left;
position:relative;
margin-left:100px;
list-style-type:none;
}
ul>li:first-child {
margin-left:0;
}
Also, is there are reason you're using position:relative on everything rather than just adding margin or padding to .page-box?

Simple menu. CSS not working in IE7

I have the following menu. Seems to work in all browser but not IE6 or IE7. What is causing the problem and How can i fix that.
Check working example at http://jsfiddle.net/2ysCC/
#menu_wrap {
margin-top:20px auto 0 auto;
padding:0;
width:780px;
height:40px;
list-style-type:none;
}
.button a {
cursor:pointer;
text-align:center;
font:13px/100% Arial, Helvetica, sans-serif;
font-weight:bold;
position:relative;
min-width:50px;
height:20px;
float:left;
padding:10px;
padding-right:0;
text-decoration:none;
}
.Red, .Red .button a {
color:#faddde;
background: #ed1c24;
}
.button:last-child a {
float:left;
border:none;
}
<ul id="menu_wrap" class="Red">
<li class="button">Home</li>
<li class="button">portfolio</li>
<li class="button">Latest</li>
</ul>
This is how it looks in IE7
Add 'display: inline;' to your 'li'.
#menu_wrap .button {
display: inline;
}
Here is an article describing the bug in further detail: http://css-tricks.com/501-prevent-menu-stepdown/
Float the li tags instead of the a tags:
.button {
float: left;
}
JSFiddle
Try to remove position: relative and make it float: left
Use this CSS, float left element <LI>
li.button{
float: left;
}