I've got an issue which i've never had before up until this site and i can't figure out the problem.
I build my sites with a wrapper set at 100% width; and a container set at 960px with a margin of '0 auto' to center the container.
Most of the time (and as with this one) i have a header wrapper/container, main content wrapper/container and footer wrapper/container.
In addition, my body is set to 100% width and height.
The problem is my header wrapper is causing a very small scroll to occur, and when i scroll right to see, the entire right of the page seems to have a 20 pixel margin.
I don't seem to get the problem in Chrome, just IE and Firefox.
My CSS is cleared with this at the beginning:
body, div, dl, dt, dd, ul, ol, li,
h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, blockquote, th, td {
margin: 0;
padding: 0;
}
My main body style is set as:
body {
float: left;
font-family: 'Verdana', 'Arial';
background: #E3E3E3;
width: 100% ;
height: 100%;
color: #5B5B5B;
}
I'm a bit embarrassed to ask this as CSS bugs are normally a breeze to get through, but i've no idea with this. As for the other wrappers, as i mentioned, they're all set as:
wrapper { float: left; width: 100%; height: 100%;}
content {width: 960px; margin: 0 auto; }
Any ideas? It's driving me insane!
Try resetting you css first. This is what I use to start my main stylesheet:
* {margin:0;padding:0;outline:0;border:0;
-webkit-font-smoothing: subpixel-antialiased !important; text-rendering:optimizeLegibility;}
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q,
samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, legend, table, caption, tbody, tfoot, thead, tr, th,
td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video
{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;}
You need to reset styles before you can troubleshoot bugs like this. Then it's a breeze...
Since the space causing the scrollbar is empty, you could just force that section to never show a scrollbar with--
overflow: hidden;
Then you can get on with the project & come back later to figure out what's causing it if you want to.
Related
I have a very old working page which I don't want to change/upgrade at all. I need to add Bootstrap 3 because I've added a popup modal but Bootstrap default CSS reset/re-styling is changing the old page so it looks awful.
Is there any simple way to prevent Bootstrap CSS changing my page by default?
I know I can add a modal without bootstrap, but I've the bootstrap modal already written and working on another page of the same website so I would like to use the same code.
A great solution to prevent overwriting is to go to this page and select the components you just want to use. This will prevent you from bringing over unnecessary code you don't need and hopefully, it will prevent it from overwriting your css. Make sure you add all your css files after bootstrap is called. Also, you could add a css reset at the beginning of your css file. Then style accordingly and add important tags.
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
I understand about CSS specificity (a bit), but I can't seem to understand a problem I am currently having.
I have a CSS Reset file, which I include before any other CSS files in my page. This file contains the following
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, figure, footer, header, hgroup, menu, nav, section, menu, time, mark, audio, video {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border: 0 none;
font-size: 100%;
margin: 0;
outline: 0 none;
padding: 0;
vertical-align: baseline;
}
Then, in my own css file (which is added after the reset), I have the following
ol, ul {
margin-bottom: 20px;
padding-left: 25px;
}
"OL" and "UL" are both single elements in the reset and custom css files - that is, neither of them have any prefix - so I would expect my own css to override the css. For some reason it doesn't.
I have been temporarily appending !important to my custom CSS, but I need to do this for almost every rule I am writing.
What am I missing?
I'm having trouble with a website I'm working on.
This is the website here. The top navigation bar is not okay at mobile/tablet view. It's okay at desktop only. See the image of mobile view:
I don't want to make it responsive but from mobile or tablet it should be same layout with scrooling. There is no problem at the code for navigation. The problem is about the div who holde the navigation.
Because if I remove the navigation and use just text, it'll have same problem:
The HTML code of the div:
<div class="outer top">
<div class="inner">
<div class="nav">
<ul>
<li>....</li>
<li>....</li>
<li>....</li>
</ul>
</div>
</div>
</div>
The CSS code:
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
border: 0 none;
font-size: 100%;
margin: 0;
padding: 0;
vertical-align: baseline;
}
body {
background: url(../images/bg.png) repeat-x #fff;
color: #fff;
font-family: Helvetica, Myriad Pro, Verdana;
font-size: 14px;
line-height: 1em;
}
.outer {
width: 100%;
float: right;
display: block;
}
.top {
background: #004481;
}
.inner {
width: 940px;
margin: 0 auto;
}
I've used width 100%. But, still it's not okay at mobile/tablet. Can you please give me a solution...
I put your code in jsbin, and wasn't able to see what you're seeing. Can you add more code?
http://jsbin.com/ologix/1/edit
You could also consider to create a new stylesheet specific for your mobile/tablet devices.
This makes sure that it will look right on all devices. You're already using Divs so that shouldn't be a problem.
So as most developers, i use a CSS RESET in all my work. One of the small problems i run into is that when developing custom anything in wordpress, i use this reset and the problem ive been having is that, because of said reset when the user is writing a post, the ability to for example, use italics / bold etc isnt available. I mean it is but its not applied because of said reset.
I just went in and removed the em / i / b etc tags from the reset block and its working BUT, theres one more thats giving me the biggest problem and thats that when someone hits the enter key to create space between text etc, nothing happens. they have to manually go in and put in <br/> tags to create the separation.
That said, it got me to thinking that....what exactly IS the css for line breaks/ the enter key?
below is whats in my CSS reset...not sure what else i have to remove.
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, img, ins, kbd, q, s, samp,
small, strike, sub, sup, tt, var, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0px;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
a{text-decoration:none;}
Ive tried to google but, aside from the p tag or the div tag etc...not sure what i have to remove to get the enter key/space created by pressing the enter key to go back to default.
Thanks in advanced.
To create separation such as a return, you can use a :after or :before like this:
p:after {
content: '\13';
display: block;
}
This will create a new line before of each paragraph element. You can use this trick with any kind of element.
Here's the fiddle:
http://jsfiddle.net/napy84/VQLTq/
Flexible layouts use ems or % as font-size units a common practice is to use body font-size as 62.5%
But Firefox's default font is 14px which results in smaller layout than others who have 16px default font size
Can't we fix just body font-size to 10px so that relative sizes works in every browser.
Also, in addition to #Ray's answer..
For browser inconsitencies like these, consider using a reset stylesheet.
A good one can be found here. and here.
I am pasting the code here for sake of reference.
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
You are saying a lot of the right things here:
Ems and percents have traditionally been the units to use for "scalable" layouts.
The "cascade" in CSS includes the browser's own style sheet. So whenever you omit a style property for some element, it searches through the cascade and will pick up these missing properties from the browser's style sheet at the end of a chain.
If you want pixel-perfect font handling for page text that looks the same across browsers, you will need to define a font-size yourself. Using px on the body element should give you what you want. I'm not aware of any reason why this is still an issue. There was a time when some people would avoid px but modern browsers handle zooming nicely now that I suspect it is much less of an issue than it was.