Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have two div elements and nav > nav_1. I am expecting to see 500x500 black color background and 50x50 blue color area on the top left but instead of showing me only 500x500 black area. how could i fix it?
.nav {
height: 500px;
width: 500px;
background-color: black;
}
.nav.nav1 {
height: 50px;
width: 50px;
background-color: blue;
}
<div class="nav">
<div class="nav_1">
</div>
</div>
First of all in your CSS, you were using .nav1 instead of .nav_1. Secondly put a space between .nav and .nav_1. Try this:
.nav .nav_1{
height:50px;
width:50px;
background-color:blue;
}
Here is a Fiddle for the same.
EDIT:
For getting a margin-top of 50px, try this:
.nav{
height:500px;
width:500px;
background-color:black;
position:fixed; /* fix position of .nav div */
}
.nav .nav_1{
height:50px;
width:50px;
background-color:blue;
margin-top: 50px ; /* put margin-top to 50px */
}
Here is the Updated Fiddle for the same.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
This is the code I wrote. but it doesn't work as I expected. There is space around the background color still and I want to cover the div with that color.
What is the issue here?
#div {
background-color: black;
margin: 0;
}
This might be happening for 2 reasons :
You don't have initial values set to 0 in CSS for the entire DOM
You have some padding on a parent element,or margin on child element that you need to get rid off
Attaching a runnable snippet for your reference
*{
margin:0;
padding:0;
box-sizing:border:box
}
.main{
background:blue;
padding:1rem;
}
.child{
background:red;
padding:1rem;
}
.grandchild{
background:yellow;
padding:1rem;
}
<div class=main>
<div class="child">
<div class="grandchild">
Text
</div>
</div>
</div>
background-color is not applied on margins. Replace margin: 0; with padding: 0;
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I want to bring my Sketch file to HTML/CSS in the browser.
How can I implement the white line just between the small and big text, as shown in the image below?
If don't want to include any additional html element then you can use pseduo element:after.
h2:after {
display:block;
content:" ";
width: 80px;
height: 5px;
background: grey;
margin-top: 5px;
}
fiddle
You can add an empty div with a bottom border & custom width, which is of cleaner and shorter code:
body {
background-color: blue;
color: white;
}
#mydiv {
border-bottom: 4px solid white;
width: 33%;
}
#myline {
height: 4px;
background-color: white;
border: 0px solid black;
width: 33%;
}
A div:
<div id="mydiv"></div>
A horizontal line:
<hr id="myline" />
That's 4 lines for the HR and 2 for the div, and that's without making the hr align to the left.
If you don't want to add another element you can use ::after on any element - just make it have display: block and set the color, width, height etc. similar to the above code.
You can add tag <hr> and him specify needed width, height,color...
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
How to make full width footer with <footer> tag.
I'm not able to use div with id and make it looks like footer (which is pretty simple).
body{
background: #333333;
}
footer{
float:left;
background: lime;
padding:15px 0;
width:100%;
}
<footer></footer>
https://jsfiddle.net/g4b3oakd/
When i use code like this it's not in full width of page.
Is possible to do something like this?
Add margin: 0; like this: https://jsfiddle.net/DIRTY_SMITH/g4b3oakd/1/
body{
margin: 0;
background: #333333;
}
footer{
float:left;
background: lime;
padding:15px 0;
width:100%;
}
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I create footer with footer tag <footer> , but my problem is I can't to change background color
Here is a code:
HTML:
<footer class="site-footer">
<div id="footer1"><p>Copyright 2013 Domain Name - All Rights Reserved </p></div>
<div id="footer2"><p> Template by OS Templates </p></div>
</footer>
CSS:
.site-footer {
background: orange;
}
#footer1{
margin-left:2%;
float:left;
}
#footer2{
margin-right:2%;
float:right;
}
Just change your site-footer to an id instead of a class with some defined height. Fiddle here.
<footer id="site-footer">
<div id="footer1"><p>Copyright 2013 Domain Name - All Rights Reserved </p></div>
<div id="footer2"><p> Template by OS Templates </p></div>
</footer>
#site-footer {
height: 50px;
background: red;
}
#footer1{
margin-left:2%;
float:left;
}
#footer2{
margin-right:2%;
float:right;
}
Your #footer1 and #footer2 divs are covering the .site-footer div, that's why you can't see the background color, try apply background transparency on this two divs.
Try changing footer element to a div. Or using backgroun:inherit for #footer1 and #footer2
Since #footer1 and #footer 2 both float .site-footer has no height.
Use a clear fix on .site-footer
hear is an example
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.clearfix { display: inline-block; }
/* start commented backslash hack \*/
* html .clearfix { height: 1%; }
.clearfix { display: block; }
/* close commented backslash hack */
Add another div in after the footer divs, with style="clear:all".
Here you go, got it working for you
background:inherit;
http://jsfiddle.net/0Lz53cad/1/
If you don't want white space between the elements use padding instead of margin.
Just as I said. Please mark my answer as the right answer.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I have a css code, "border-top" is not displaying correctly. I've done everything correctly but I just don't see the problem.
JSFiddle: http://jsfiddle.net/3vnWh/1/
Code:
div.topb {
border-top: 1px solid #dcdcdc;
}
you have and open { and selector:
fiddle
/* optional div height ,width, color */
{ /*this is missing*/
width:400px;
height:200px;
background-color:#ffffff;
font-size:28px;
color:#ffffff;
}
You should use
table.topb
instead of
div.topb
The section immediately before div.topb has no opening brackets or labels. If you comment this section out or give it the appropriate opening brackets, your border-top will display properly. Your section looks like this and can be fixed by adding a { before the width line:
/* optional div height ,width, color */
width:400px;
height:200px;
background-color:#ffffff;
font-size:28px;
color:#ffffff;
}
use any of the following
.topb
{
border-top: 1px solid #dcdcdc;
}
OR
table
{
border-top: 1px solid #dcdcdc;
}
OR
table.topb
{
border-top: 1px solid #dcdcdc;
}