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.
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?
How is it possible that there is a 3 px difference in the vertical position of textfields in a form when seen in those 3 diff. browsers?
I am going insane. It is not good trying to fix it in the CSS because if I change it, it is fine in one but not in the others.
#pricefromR
{width:75px;
position:relative;
right:40px;
top: 50px;
}
#pricetoR
{width:75px;
position:relative;
right:-45px;
top: 24px;
}
So this corresponds to two texfields which are supposed to be paralell, at the same leve with each other, but they are not in different browsers, by a difference of 3 px and it happens the same with the other pairs which are each in a LI
<li>
<input type ="text" id = "areafromR" placeholder="area from" name = "areafrom" maxlength = "5">
<input type ="text" id = "areatoR" placeholder="area to" name = "areato" maxlength = "5">
</li>
All browsers are different, they have different defaults, and different wu=idths/heights. The best way that I know of is to either use percents, but that can get complicated. You can make a the CSS seperate for different browsers. For example ...... That is for internet explorer
You should try to reset your CSS
In case you didn’t know, every browser has its own default ‘user
agent’ stylesheet, that it uses to make unstyled websites appear more
legible. For example, most browsers by default make links blue and
visited links purple, give tables a certain amount of border and
padding, apply variable font-sizes to H1, H2, H3 etc. and a certain
amount of padding to almost everything. Ever wondered why Submit
buttons look different in every browser? It limits the difference
between browsers
Using a CSS Reset, you can force every browser to have all its styles reset to null, so less cross-browser differences
With this code:
/**
* Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
* http://cssreset.com
*/
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;
}
A common practice is to put this in another CSS file.
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/
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.