this html code is css-doodle example.
In this image, '#grid' is error.
why? and how to use #grid in html body?
I want to use css-doodle
Related
I am trying to create PDF files from HTML. Now I want to apply a Background on my pages.
But #page {background: blue;} seems to be not supported.
I tried to add the background to the body but this causes other issues. At first, I need to specify backgrounds for first page, and another for all other pages.
Further more, the resulting Document looks like this:
This is not what I want. I need the background to cover the full page but the content should be inside the page border.
It should look something like this:
For this, I added padding to the body. But there are still problems. The background is not printed on the second page, the text is not inside the margin then breaking the page and I cannot set special background for the first page.
This is my HTML & CSS for the second result. For the first, the only difference is, that margin was added to #page instead on body.
html = """
<html>
<head>
<style>
#page {
size: A4;
margin: 0;
}
body {
background: #002244;
color: white;
padding: 2cm;
box-sizing: border-box;
}
</style>
</head>
<body>
""" + get_text() + """
</body>
</html>
"""
It is rendered and printed using pyppeteer`s page.pdf method.
How can I create a background, which covers the full page with text which is inside the page borders? And how can I set separate backgrounds for the first page?
I am simply adding a header navbar to an html page.But the problem is its not aligned exactly to the top.There is a small gap between the browser and the navbar.I found a solution as setting margin:0;,but the issue I have is it will only work if I code it as by selecting the whole div... like
*{ margin:0;}
why is that so ?
I found this solution in another stackoverflow question but I cant comment and ask because I have low repuation.He is stating its because of SASS.But how is my code becoming sass because I was using normal simple procedure for CSS coding.
Linked soultion question.(Please check the comments in correct selected question)
Header not touching top of screen
My code :
<html>
<head>
<style>
* {
margin:0;
}
.new {
width:100%;
background-color: blue;
}
</style>
</head>
<body>
<div class="new">New Website</div>
</body>
</html>
Some browser have set user agent stylesheet at "body" tag
For Chrome: body have margin: 8; on body tag, so you will get a small gap between navbar.
You can set
body{
margin: 0;
}
Will solve your problem.
http://jsbin.com/luqoruqewa/edit?html,output
Don't put the margin: 0; on the div. Put it on the body or html tag. Like so:
body{
margin: 0;
}
Don't forget that you can style the html and body tags too! Making them height: 100%; might be of use in the future.
* is the universal selector. It targets all elements. When you state:
* {margin: 0}
You're removing the margin from every element on the page. That works in this case, but it will have side effects that you probably won't want on a page with more content.
Your browser is adding some padding to the body element. As amoyer pointed out, set the body margin to zero and you should be fine.
I have this code in HTML:
.body { background: url('bg.png'); }
I have the HTML file in the same folder as the image, and the image has exactly the same name. I don't have a separate CSS folder, this code is inside in my HTML file.
I have looked at other people with the same problem and none of the responses work.
Any response will be appreciated, even if it does not work. Thank you for your time!
The body tag is a tag, not a class. Remove your dot:
body { background: url('bg.png'); }
Apply to this:
<body>
.body refers to an element with a class body, to refer to the body tag just get rid of the dot...unless that was a typo.
I am using LESS with bootstrap and trying to create a simple gradiant but if I use it on the body tag I get a broken gradiant like this image.
http://i.imgur.com/nIyOeQY.png
and if I use it with the html tag I get something like this image (it starts after the div and section tags)
http://i.imgur.com/OSe3Qt3.png
Here is the code:
.bg_gradient(#start-color: #color-grad-top, #end-color: #color-grad-bot) {
background-color:#start-color;
background: -webkit-linear-gradient(#start-color, #end-color);
background: -o-linear-gradient(#start-color, #end-color);
background: -moz-linear-gradient(#start-color, #end-color);
background: linear-gradient(#start-color, #end-color);
}
html {
height: 100%;
.bg_gradient(#color-grad-top, #color-grad-bot);
}
What am I doing wrong? Thanks for your help.
I think i might have found the solution, I added the gradient to the html tag and made the body tag's background-color rgba making it transparent. that way the gradient fills the background.
I'm writing an external user stylesheet for an old HTML page that specifies the background colour in the body tag: <BODY BGCOLOR="#808000"> (note: I can't edit the HTML).
I've tried writing the obvious stylesheet:
body {
background-color: #ffffff !important;
}
but it has no effect: the original colour remains.
Can it be done with CSS? If so, how?
FIX:
I've checked it in my place it works
body
{
background-color: white;
}
You can also do
<body style="background-color:red"></body>
It works fine here (I tested it). Are you sure the stylesheet is being imported properly?