This question already has answers here:
How wide is the default `<body>` margin?
(4 answers)
Closed 1 year ago.
I would like to remove the margins from my site so I don't get the scroll bars, but I can't, I've tried margin 0 and padding 0, but it still didn't work.
as you can see, it has margins on the top and on the left and the scroll bars are on the bottom and on the right
my code:
<template>
<div>
</div>
</template>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
height: 100vh;
width: 100vw;
background-color: blue;
margin: 0;
padding: 0;
}
</style>
Try with
* {
margin: 0;
padding: 0;
}
Related
This question already has answers here:
How wide is the default `<body>` margin?
(4 answers)
Closed 2 years ago.
I want to make the image to fully right and top side of the screen.
body{
font-family: 'Roboto', sans-serif;
font-weight: 300;
background: #822B2B;
color: #ffffff;
overflow: hidden; }
#showcase{
display: flex;
justify-content: center;
align-items: center;
text-align: center;
/* margin-left: 116px; */
/* width: 180vh; */
height: 100vh;
background: url('https://images.pexels.com/photos/1402787/pexels-photo-1402787.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260') no-repeat center center / cover; }
Please feel free to ask anything in need of clarification.
Code at: https://codepen.io/zaidik/pen/WNQYbXz
Add margin:0; to your body CSS rules
This question already has answers here:
How wide is the default `<body>` margin?
(4 answers)
Closed 2 years ago.
I have tried setting the padding and margins to 0. I have tried making the overflow-x and overflow-y values hidden. I have tried to set the width to 100% or 100vw. I don't really know what else to do, but i still have this whitespace.
here is the css attached to my header:
header{
text-align: center;
background: url("https://images.unsplash.com/photo-1579128860537-64fcd61568bf?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2559&q=80");
background-size: cover;
background-position: center;
color:white;
font-size: 22px;
font-family: serif;
height:100vh;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
Don't forget to zero out the margin on the body.
header{
text-align: center;
background: url("https://images.unsplash.com/photo-1579128860537-64fcd61568bf?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2559&q=80");
background-size: cover;
background-position: center;
color:white;
font-size: 22px;
font-family: serif;
height:100vh;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
body { margin: 0; }
<header></header>
jsFiddle
Your header style is fine, it is the margin of your body that you need to set to 0. Simply add this style to your css file:
body {
margin: 0;
}
Edit:
Another solution is to add normalize.css to your project: its a modern, HTML5-ready alternative to CSS resets.
You can read more about it here.
JSFiddle
The margin on the body defaults to 8px. You just need to set this value to 0.
body {
margin: 0;
}
This question already has answers here:
How can I center text (horizontally and vertically) inside a div block?
(27 answers)
How can I vertically center a div element for all browsers using CSS?
(48 answers)
How can I horizontally center an element?
(133 answers)
Closed 4 years ago.
I have two questions, why does the position relative make the part where the h1 header is white even thought the background colour is blue?
How would I center this element so it's always centered no matter on the screen size?
<h1 id="maintitle">Find your new css!</h1>
html {
background-color: rgb(171, 248, 235);
font-family: sans-serif,Tahoma, Verdana, 'Times New Roman';
}
h1#maintitle {
position: relative;
margin: 0 0 0 0;
width: 400px;
padding: 10px;
width: 50%;
top: 50%;
}
https://jsfiddle.net/hbudyxkq/1/
body {
background-color: rgb(171, 248, 235);
font-family: sans-serif,Tahoma, Verdana, 'Times New Roman';
}
h1#maintitle {
margin: 0 0 0 0;
text-align: center;
}
<h1 id="maintitle">Find your new css!</h1>
I have a problem that I just can't wrap my head around, it might be because that I'm tired. I'm using Ryan's Fait sticky footer which I'm sure the most of you are familiar with. I use it regularly and never had any problems with it until now. The design that I'm working has a footer with several inner child elements.
One of the elements .newsletter is using padding or margins to make a wide gap so that a background image can be placed on the body. This is causing a overflow even when entering the correct height. Deleting the padding corrects the problem. I know that using overflow: hidden is an option but I'd rather find out the cause.
Screenshot with margins or padding set within the news letter element:
Screen without margins or padding set in the news letters:
Not working CSS:
body {
background: #212121;
color: #ddd;
padding: 0;
margin: 0;
font-family: "Open Sans", "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;
font-weight: normal;
font-style: normal;
line-height: 1;
position: relative;
cursor: default;
height: 100%;
}
.maincontainer {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -424px;
width: 100%;
}
.mainfooter, .push {
height: 424px;
width: 100%;
}
.newsletter {
padding: 1.875rem 0 1.875rem;
}
.newsletter-fix {
background: #000;
padding: 3rem 0 1rem;
color: #ddd;
}
Working CSS:
Simply changing the following values from those mentioned above to the following resolves the issue but I want the padding, or margin gap between the newsletter.
.maincontainer {
margin: 0 auto -394px;
}
.mainfooter, .push {
height: 394px;
}
.newsletter {
padding: 0;
}
What if you put background-color : black to your .mainfooter instead of putting the background-color to the different element inside your footer?
It would seem that I'm extremely tried and stupid! I thank everyone for taking the time to take a look but it seems its as simple as a user error.
The problem was because I was counting from the very first bit of colour, in this case background: #000 on the .newsletterfix and not taking into consideration of the invisible padding above it. Stupid, me.
Example:
This question already has answers here:
How to remove the space between inline/inline-block elements?
(41 answers)
Closed 7 years ago.
I've searched for other solutions here in stackoverflow but found no luck unfortunately. If there is an answer that already exist to my question then I apologize, and please link the answer to me :)
Anyway I have to divs but display: inline-block; is not working. I want them to be right next to each other WITHOUT using float. How do I achieve this? I must be missing something here..
here's the jsfiddle - https://jsfiddle.net/frxme8z8/
Thanks in advance folks!
.context {
box-sizing: border-box;
width: 50%;
padding: 10px;
background: #72ED80;
font-family: 'Source Sans Pro', sans-serif;
display: inline-block;
height: 200px
}
just set your .context width to 49 %
.context {
box-sizing: border-box;
width: 49%;
padding: 10px;
background: #72ED80;
font-family: 'Source Sans Pro', sans-serif;
display: inline-block;
height: 800px
}
<div class="context"></div>
<div class="context"></div>
The answer from #imGaurav is correct. Because you've set the size to 50% there is nomore space for the gap between ;)
So just set the width to 49% and everything will work :)
.context {
box-sizing: border-box;
width: 49%;
padding: 10px;
background: #72ED80;
font-family: 'Source Sans Pro', sans-serif;
display: inline-block;
height: 800px
}
Otherwise you can change you're padding to 0px but then, you don't have a gap between it anymore ;)
your problem is the whitespaces. I see u did it with 50% - 10px...the correct way is 50% - 8px actually...OR if u want a cleaner version, just remove the whitespace in your html file like in this fiddle i made https://jsfiddle.net/r9LrLva1/