for some unknown reason, my navigation bar is shifted over to the right, on Firefox and also on Chrome. See http://i.stack.imgur.com/dskZy.png
And what's weird is that the issue doesn't arise on jsfiddle. See http://jsfiddle.net/bMAGX/
Any ideas? Thanks.
Are you using a CSS Reset? I'm guessing not. You should consider using one to help with issues like this.
I think you need this CSS to remove the default ul margin/padding:
#topmenu ul {
margin: 0;
padding: 0
}
Perhaps because your DOCTYPE is malformed.
<!DOCTYPE html> should be one of the types defined here.
You can add this to top of your CSS:
* { padding: 0; margin: 0;}
Related
When we are creating a web page using bootstrap we can set margins. But web browser also gets some margins. Although code as div(class="container-fluid") or code as margin:0; and padding:0; based on the container in the CSS file, I couldn't solve the problem. Can you help me?
Some browsers have a margin on the body tag. Set that to 0 somewhere in your css.
body {
margin: 0;
}
This is Browser default margin for body:
Fix It Like this:
body {
margin:0;
}
Set the margin to zero on any element is simple just type something like
body{
margin:0
}
Although sometimes bootstrap has his own margin rules included like setting margin on h tags, you could remove them as well by using more specific rules (read about specificity here) or by using important
h4{
margin: 0 !important
}
The reason for that is browsers have default styling for elements.
To reset margin only on body element you can use:
body {
margin: 0;
}
To reset all styling (which is not so-bad thing) in all browsers you can use css library called normalize.css.
Normalize.css makes browsers render all elements more consistently and in line with modern standards. It precisely targets only the styles that need normalizing.
This library is used by big companies as GitHub, Twitter, Soundcloud, Guardian, Medium and many others.
Although you put container-fluid, sometimes it doesn't make the width 100% fit the screen because browsers make a default margin and padding.To make it fit the screen you have to do like this.
body{
padding: 0;
margin: 0;
}
If it doesn't work make them important as following.
body{
padding: 0 !important;
margin: 0 !important;
}
I'm learning CSS, and trying to make a default rule:
* {
margin: 0px;
padding: 0px;
}
It's not working, and I don't know why... can you please point me in the right direction?
Its certainly because your body has padding of 50px; which overwrites the rule of html as far your page's body is concerned.
Edit :
body
{
margin : 0px;
padding : 0px;
}
hope you problem is solved now.. :)
Add first you should include a normalize stylesheet. The different browsers have different default styles and this stylesheet will bring one standard to all browsers.
http://necolas.github.io/normalize.css/
I think this will help you ;)
body {
margin: 0px !important;
padding: 0px !important;
}
On CSS part don't use html comment. Thats reason, why doesn't work your css part.
LIke this please write margin and padding in body tag
you have used padding:50px; in your body tag please remove padding,thats * not working properly
DEMO
body{
margin:0;
padding:0;}
here both of working please check demo
*{
margin:0;
padding:0;}
Your are using unordered list to create menu.
by default, It has those intend properties, you can override by using below code, which is not advised.
*{
margin : 0px;
padding : 0px;
}
Demo 1 & Demo 2
Also change background-color : ABC; to background-color : #ABC;
I'm having some trouble with the margin-left CSS property. I have some nested unordered lists. This is what the list looks like with no change to the margin-left (in both IE and Chrome):
I wanted to decrease how much each list is indented so I added this CSS code:
ul li ul
{
margin-left: -25px;
}
This works fine in Chrome, which displays this:
However, IE 8 displays it like this:
I guess the origin of where the margin starts is different between the two browsers? How can I achieve the desired affect of decreasing the indentation of nested unordered lists among all browsers?
You should look into "zero-ing out" the margin and padding for ul and li's like so:
ul,li { margin: 0; padding: 0; }
As different browsers have different defaults. From there, you should be able to add your own margins and paddings as desired.
It's a good thing to use always a CSS reset. This will avoid having differences among browsers. You could use a universal reset like;
* {
margin: 0;
padding: 0;
outline: 0;
/* etc */
}
Or going a bit deeper and use Eric Meyer's one or anyone else. There are a few.
Anyway, in your case instead of play with negative margins, you should reset your margin and padding for ul and li elements:
ul, li {
margin: 0;
padding: 0;
}
I suggest http://necolas.github.io/normalize.css/ or a standard reset css stylesheet
Different browser set different default settings.
On the site I'm working on, for some reason the margin is needing to be different for Safari than in FF, IE8, Chrome & Opera? I have a link that I want lined up next to a label. It's lining up fine in all but Safari which needs a 12 pixel difference. Here's a screenshot to better describe the issue: Click
The Safari screenshot shows the label down too low. This is the CSS I use for the working 4 browsers:
.submitter a {
float: right;
margin: -2px 0 0 2px;
padding: 0 !important;
}
And here's the code that works for Safari, however, usig it throws the link UP 12 pixels.
.submitter a {
float: right;
margin: -14px 0 0 2px; Works in Safari & Chrome
padding: 0 !important;
}
Anyone able to shed some light on this? TIA
This seems to sort it out:
.submitter a {
float: none;
display: inline !important;
margin: 0 0 0 2px;
}
It's really very convoluted in there due to nonsensical use of the cascade.
Some rules are being applied to elements where they really shouldn't be due to selectors like:
.box_777 ul li a
You'd be better replacing that selector with something like:
.individual-likes > a
But, it's difficult to predict how improving your selectors will change how your page displays.
The reason it goes up like that could be because of the - pixel value. Are they nested correctly in the div? And did you apply the same alignment (CSS, Html, etc.) for the Chrome buttons?
There is a lot going on, but you might try one of the following:
.submitter .smalltext { float: left; }
(or)
Move the "follow" anchor tag before the "smalltext" span
Looking at the site, the anchor is being set to block by .box_777 ul li a and then floated right by .submitter a.
If I remove the display: block; and float: right; things align.
Something seems to be breaking the display of lists (ul and ol) in IE7. They work fine in IE8, FF, Safari etc but not IE7 and IE6.
I just want them to be displayed normally: ul lists should show bullet points and ol lists should show numbers.
I've narrowed it down to the first 1000 lines of code in styles_layout.css... ;)
Actually, I believe it has something to do with the following styles:
* { margin: 0; }
html, body { height: 100%; }
.wrapper
{
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -39px;
}
Have a look here: http://www.olvarwood.com.au/olvarwoodonline/mod/forum/discuss.php?d=2, login as a guest
IE7 and below style ul elements like this:
ul {
margin-left: 40px
}
Good browsers style ul elements like this:
ul {
padding-left: 40px
}
It's better explained by Eric Meyer here:
https://developer.mozilla.org/en/Consistent_List_Indentation
and the section "Finding Consistency" will tell you what you do.
This is because the ul/li elements have inherited the zero-margin property.
I solved it myself through trial and error:
* {
margin: 0;
}
This stops Ol's and Ul's from displaying properly in IE7 and IE6. I have no idea why...
I won't even pretend to be an expert on css, I get my butt kicked by it all the time, but I just happened to run into this, although my situation was a bit different.
I ended up having to specify a class tied to ul and set the list-type.
.classname ul { list-style disc inside }
Try that and see if it helps.