Weird !important margin - html

I am working on a website now and I have just started with the header. But for some odd reason it gives 28px margin on top. When I inspect, it says it's because of this:
media="screen"
html {
margin-top: 28px !important;
}
HTML
<header>
<div id='header_container'>
<h1><?php bloginfo('name'); ?></h1>
<?php wp_nav_menu( array("theme_location"=>"main") ); ?>
</div>
</header>
This is all my css
* {
margin: 0;
padding: 0;
}
#wrapper {
margin: 0 auto;
width: 960px;
}
header {
width: 100%;
height: 81px;
background-color: grey;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
div#header_container {
width: 960px;
margin: 0 auto;
}
div#header_container>h1 {
margin: 0 auto;
}
div#header_container>h1 {
font-family: arial;
font-size: 14px;
}
div#header_container>h1 a {
background-image: url(images/logo.svg);
width: 272px;
height: 19px;
display: block;
text-indent: -9999px;
float: left;
}
/* menu thing */
ul#menu-main-menu {
list-style-type: none;
}
ul#menu-main-menu>li {
margin: 0;
padding: 0;
}
ul#menu-main-menu>li>a {
display:block;
float: left;
padding: 10px;
margin: 0 5px 0 0;
text-decoration: none;
}
I can't find the margin, can you? I am confused where it comes from.

I found the answer:
If it's acting up on your site, open your user profile (Users > Your Profile) and uncheck the 'Show on Front' option to make it disappear.
But thanks for your help guys!
Cheers

I think you are using wordpress, that's something related to the admin top bar which can be disabled by plugins but the css rule remained enabled.
CSS rules marked !important take precedence over later rules.
To fix this issue you may add in your css file the following code at the top and at the bottom. But you must put !important so it will override the previous rule. Or, you can add inline style in the html tag.
html {
margin-top: 0px !important;
}

Related

How to make a navbar span 100% of the page

this might be a really stupid question, but I recently started getting into web development again as a hobby, and I am trying to create a simple website to remember what I knew.
Unfortunately, I ran into a roadblock: I want a navigation bar that spans 100% of the page, but no matter what I try, there are still tiny margins to each side, like this:
The website
Right now, the relevant CSS looks like this:
body {
background-color: beige;
}
.navbar {
background-color: black;
overflow: hidden;
margin: 0 0 1em 0;
float: left;
width: 100%;
display: inline-block;
}
.navbar a {
background-color: #dddddd;
color: black;
float: left;
font-size: 24px;
padding: 16px 16px;
text-decoration: none;
}
.navbar a:hover {
background-color: #777777;
color: white;
}
.navbar a.active {
background-color: coral;
color: white;
}
Andrew provided a nice answer for you but to not run into this kind of problem again I suggest always adding this to your main .css file.
* {
margin: 0;
padding: 0;
outline: 0;
box-sizing: border-box;
}
Otherwise just add this to the html and body elements.
The gaps are most probably from your parent body element. Add the following to your CSS to remove those gaps:
body {
background-color: beige;
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
}

CSS isn't showing up on a specific part of the page

So I'm working on a website I'm building and am in the process of consolidating stylesheets. I'm currently having a problem where one div section of the page is not connecting to the stylesheet. The rest of the page is fine but it's just this one section and I have no idea why. I copied and pasted it (html and style) from the first draft and am using the same fonts and bootstrap cdn (bootstrap fonts 4.1 and bootstrap cdn 3.3.7) but am getting different results. Would appreciate any help you could offer.
here's the html
<div class="main">
<div class="container">
<header>
<center><h2>My Work</h2></center>
</header>
<div class="box">
<span class="image featured"><img src="laptopstock.jpg" alt="" /></span>
<h3>Arris SURFboard SBG6700-AC Wireless Gateway Manual</h3>
<p>The Arris SURFboard SBG6700-AC wireless gateway is the premier modem on the market today. It's top of the line security, simple user interface and blazing fast speeds make it the number one consumer choice for modems. With this guide you can set up your home wireless network in 30 minutes.</p>
<br>
<p>Learn More</p>
</div>
</div>
</div>
here's the css
main {
padding: 8em 0;
}
main.header {
text-align: center;
margin: 0em 0 3em 0;
padding-top: 1000em;
}
/* difference between padding and margin?
padding is on the inside.
margin on the outside.*/
/* this is the gray space between the header and the image */
main.header h2 {
font-size: 2.75em;
margin: 0;
letter-spacing: .005em;
color: #000;
}
body.landing main {
margin-top: -14em;
}
.container {
margin-right: auto;
margin-left: auto;
padding-right: 15px;
padding-left: 15px;
width: 100%;
}
.box {
margin: 1em;
overflow-x: hidden;
padding: 2em 2em !important;
}
.box.features .features-row {
border-top: 0;
padding: 0;
}
.box.features .features-row section {
border: 0;
border-top: solid 1px #e5e5e5 !important;
float: none;
margin: 2em 0 0 0 !important;
padding: 2em 0 0 0 !important;
width: 100%;
}
.box.features .features-row:first-child section:first-child {
border-top: 0 !important;
margin-top: 0 !important;
padding-top: 0 !important;
}
.box .image.featured {
margin-left: -2em;
width: calc(100% + 4em);
}
.box .image.featured:first-child {
margin-bottom: 2em;
margin-top: -2em;
}
.box .image.featured:last-child {
margin-bottom: -2em;
margin-top: 2em;
}
Your element selector is wrong. From your html, 'main' is a class, 'header' is an element. To refer to class in css, use '.' as in .main, to refer to element, use the tag name directly. Writing main.header means and element 'main' that has class 'header' which is not what you want. Use the Css instead;
.main {
padding: 8em 0;
}
.main header {
text-align: center;
margin: 0em 0 3em 0;
padding-top: 1000em;
}
/* difference between padding and margin?
padding is on the inside.
margin on the outside.*/
/* this is the gray space between the header and the image */
.main header h2 {
font-size: 2.75em;
margin: 0;
letter-spacing: .005em;
color: #000;
}
That should work. Let me know how it goes.
center tag is deprecated in your html header. Replace with text-align in css. An example would be: h2 { text-align: center; }

Remove white spaces between img

i'm using blogger and I want to know how can I remove the white spaces between a img and a text, because is a lot separated. Blogger contains a class called separator but I don't know what to do for fix that.
Here's a image:
How can I remove it?
This is my css
.separator{
margin: 0;
display: block;
padding: 0;
}
.post img {
display: block;
text-align: center;
padding: 0px;
margin: 0px;
}
CSS
/* Posts-----------------------------------------------*/
h2.date-header{margin:1.5em 0 .5em;display:none;}
.wrapfullpost{display: block;}
.post{
display: block;
margin: 0;
}
.post img {display: block;
margin: auto;
text-align: center;
padding: 0;
}
.post-title{color:#333333;margin:0 0 10px 0;padding:0;font-family:Arial,Helvetica,Sans-serif;font-size:24px;line-height:24px;font-weight:bold;}
.post-title a,.post-title a:visited,.post-title strong{display:block;text-decoration:none;text-decoration:none;}
.post-title strong,.post-title a:hover{text-decoration:none;}
.post-body{
font-size: 17px;
display: block;
margin: 0;
}
.entry-content{ padding: 0; margin: 0; display: block;
}
.separator{
margin: 0;
display: block;
padding: 0;
}
.post-footer{margin:5px 0; font-weight: 300;}
.comment-link{margin-$startSide:.6em}
.postmeta-primary{color:#999;font-size:12px;line-height:18px;padding:0 0 5px 0}
.postmeta-secondary{color:#999;font-size:12px;line-height:18px;padding:0 0 10px 0}
.postmeta-primary span,.postmeta-secondary span{padding:3px 0 3px 20px;background-position:left center;background-repeat:no-repeat}
.meta_date{background-image:url(http://2.bp.blogspot.com/-paWPYJvQDqA/UC7eiuIKgUI/AAAAAAAAAvw/af410sUcO2w/s000/date.png)}
.meta_author{background-image:url(http://3.bp.blogspot.com/-reTaoyVmDXA/UC7ejgVBQbI/AAAAAAAAAv4/u6d-iPeLZi0/s000/author.png); border-right: 1px solid #ccc;
padding-right: 10px!important;
m
argin-right: 5px;}
.meta_comments{background-image:url(http://2.bp.blogspot.com/-zZgvwATiF3E/UC7ej-cvmbI/AAAAAAAAAwA/THMs0579MII/s000/comments.png) }
.meta_edit{background-image:url(images/edit.png)}
.meta_categories{background-image:url(http://1.bp.blogspot.com/-g-ptS39XbNM/UC7ekTJsEXI/AAAAAAAAAwI/t8fMhUuUvQI/s000/category.png)}
.meta_tags{background-image:url(http://3.bp.blogspot.com/-fZuK3yymXmo/UC7ek6kEDLI/AAAAAAAAAwQ/-J16r4bHvFo/s000/tags.png)}
.readmore{margin-bottom:5px;float:right}
.readmore a{color:#F85B48;background:#EAEAEA url(http://4.bp.blogspot.com/-m6AJDK0k2xA/UC7emOYbEbI/AAAAAAAAAwY/Q4o73QiZdc4/s000/readmore-bg.png) left top repeat-x;padding:8px 14px;display:inline-block;font-size:12px;line-height:12px;text-decoration:none;text-transform:uppercase}
.readmore a:hover{color:#fff;background:#E74F3D url(http://4.bp.blogspot.com/-m6AJDK0k2xA/UC7emOYbEbI/AAAAAAAAAwY/Q4o73QiZdc4/s000/readmore-bg.png) left -126px repeat-x;text-decoration:none}
And this is what blogger add in HTML
<div class="separator" style="clear: both; text-align: center;">
<img border="0" src="http://3.bp.blogspot.com/-DGgnyTkp3xc/VAtkSdWZLxI/AAAAAAAAAb4/oXctHDcrSRk/s1600/Sinopsis%2Bwissar.png" height="160" width="640" /></div>
Since you didn't share any of your code, It's hard to explain where is the problem (You may get negative rep).
but i can suggest you to look at your style classes. try following, it's just a removal of Padding, and Margin
.imageClass{
padding: 0px;
margin: 0px;
display: block;
}
.textClass{
padding: 0px;
margin: 0px;
display: block;
}
Within the seperator class there is a blockquote which contains the text, and an a tag which is a link containing the image. Both of these have margins that you do not want. Try this.
.seperator blockquote {
margin: 0px;
}
.seperator a {
margin-right: 0px;
}
Note: Remove what was in my previous answer.
If you can't get it to work, go to the section on your webpage that you want to change, right click -> inspect element. This will bring up the HTML inspector. You can then click on different elements and see the css on the right hand side that relates to that element. Try unticking different css statements or changing them/adding new ones. Just continue to play around with it until you can get it. I really can't be of any more help.
Solved, just added the next
.separator {
display: block;
line-height:0;
margin: 0;
padding: 0;
}
.separator blockquote {
margin: 0;
}
.separator a {
margin-right: 0;
}
Thanks to Yep_It's_Me who helped me a lot.

Layout problems with CSS

I got some problems with layouting in CSS. Here is the code I am talking about: Fiddle.
The <div id="header"> should have the height of the <div id="menubuttons"> which I marked red.
I always thought that if you don't state the height of a div it will get the height of it's children.
The <div class="contentLine> is stuck to the <div id="theme"> although I defined margin-top: 20px;.
The right column always has greater margin than the left column. I want both to have the same margin to the browser window.
CSS
body {
margin: 0 auto;
padding: 0;
font-family:'Share', cursive;
}
#header {
width: 100%;
vertical-align: middle;
}
#header_logo {
width:;
float: left;
margin: 11px 20px 20px 20px;
background-color:;
}
#menubuttons {
margin-right: 0;
margin-top: 0;
height: 2.5em;
line-height: 2.5em;
display: inline-block;
background-color: red;
}
#menubuttons ul {
list-style-type: none;
margin:0;
padding:0;
}
#menubuttons li {
float: left;
margin-right: 20px;
}
a {
font-family:'Share', cursive;
}
a:link {
text-decoration:none;
}
a:visited {
text-decoration:none;
}
a:hover {
text-decoration:underline;
}
a:active {
text-decoration:underline;
}
#theme {
width: 100%;
height: 400px;
background-color: green;
margin-top: 0;
float: left;
}
.contentLine {
margin: 0 auto;
margin-top: 20px;
width: 96%;
}
.contentLine .column {
float: left;
margin: 0;
width: 30%;
margin-right: 1%;
padding: 1%;
position: inherit;
/* shadow for seeing div boundaries */
box-shadow: 0 0 1px black inset;
}
.contentLine #last {
margin-right: 0;
}
Let me go 1 by 1
1) Your <div id="header"> contains floated elements, you need to clear that, so use overflow: hidden; on parent element i.e #header
2) Again, you've floated #theme but you've set it to width: 100%; so you don't need float there.
3) About the last you need to set the margins accordingly, right now it's 1% so you need to calculate this correctly, I would like to suggest you to use box-sizing: border-box; and set 33% width for each element and than apply padding-right
Demo
Also make sure you clear your floating elements which are nested inside contentLine.
If you are not one of those IE fans, than you can use the snippet below, which will self clear the parent element in a better way.
.clear:after { /* Much much better than overflow: hidden; */
content: "";
display: table;
clear: both;
}
Update your html
</ul>
<!--Menu ends here -->
</div>
<!--menubuttons ends here -->
<!--Add following div to your code -->
<div class="clear"></div>
</div>
<div id="theme">
Update your CSS
.clear{
clear:both;
}
This should help.
- will be reusable also.

Using css sprites without html

I have created a css sprite image for multiple images. The css for sprite is:
.sprites {background-image:url("/images/max.png");background-color:transparent;background-repeat:no-repeat;}#image_5306605314403955_gif {height:10px;width:10px;background-position:0 0;}#image_2814089791124994_gif {height:8px;width:8px;background-position:-10px 0;}#image_05699283026450497_gif {height:36px;width:50px;background-position:-18px 0;}#image_23591702358881883_gif {height:9px;width:11px;background-position:-68px 0;}#image_9167572062810537_gif {height:10px;width:10px;background-position:-79px 0;}#image_21043553959746242_gif {height:16px;width:16px;background-position:-89px 0;}
Now I want to assign the first image from this sprite to an li element. Currently the first images is assigned using background:url property of this li as:
li{margin-top:0;padding:3px 0 3px 25px;background:url(../images/arrow.gif)
How can bring the first image from sprite and assign to the li element. I have seen an example which suggests to use:
<div class="sprites" id="image_5306605314403955_gif"></div>
But I want to see if adding HTML can be avoided and use CSS only for that purpose. The li element on my page looks like:
<li>ABC</li>
I am not sure if that is what you are looking for or not, but the below code should do it:
HTML:
<li class="sprites"><a id="image_5306605314403955_gif" href="http://www.xyz.com">ABC</a></li>
<li class="sprites"><a id="#image_9167572062810537_gif" href="http://www.xyz.com">ABC</a></li>
CSS:
.sprites {background-image:url("/images/max.png");background-color:transparent;background-repeat:no-repeat;}
#image_5306605314403955_gif {height:10px;width:10px;background-position:0 0;}
#image_2814089791124994_gif {height:8px;width:8px;background-position:-10px 0;}
#image_05699283026450497_gif {height:36px;width:50px;background-position:-18px 0;}
#image_23591702358881883_gif {height:9px;width:11px;background-position:-68px 0;}
#image_9167572062810537_gif {height:10px;width:10px;background-position:-79px 0;}
#image_21043553959746242_gif {height:16px;width:16px;background-position:-89px 0;}
If what you are looking for is not to use class or id, then I think it is impossible, as your CSS needs an identifier to differentiate between your items (which are inherited from the same class <li>)
body {
overflow-y: scroll
}
.mini_iframe,
.serverfbml_iframe {
overflow-y: visible
}
.auto_resize_iframe {
height: auto;
overflow: hidden
}
.pipe {
color: gray;
padding: 0 3px
}
#content {
margin: 0;
outline: none;
padding: 0;
width: auto
}
.profile #content,
.home #content,
.search #content {
min-height: 600px
}
.UIStandardFrame_Container {
margin: 0 auto;
padding-top: 20px;
width: 960px
}
.UIStandardFrame_Content {
float: left;
margin: 0;
padding: 0;
width: 760px
}
.UIStandardFrame_SidebarAds {
float: right;
margin: 0;
padding: 0;
width: 200px;
word-wrap: break-word
}
.UIFullPage_Container {
margin: 0 auto;
padding: 20px 12px 0;
width: 940px
}
.empty_message {
background: #f5f6f7;
font-size: 13px;
line-height: 17px;
padding: 20px 20px 50px;
text-align: center
}
.see_all {
text-align: right
}
.standard_status_element {
visibility: hidden
}
.standard_status_element.async_saving {
visibility: visible
}
img.tracking_pixel {
height: 1px;
position: absolute;
visibility: hidden;
width: 1px
}