Position relative overwrites background colour [duplicate] - html

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>

Related

How to center an HTML element horizontally and vertically in CSS? [duplicate]

This question already has answers here:
How can I vertically center a div element for all browsers using CSS?
(48 answers)
Flexbox: center horizontally and vertically
(14 answers)
Closed 1 year ago.
I have an HTML element inside another. How can I center it by two dimensions of a wrapper at one time using CSS?
I'm trying this code:
.wrapper {
heigth: 10rem;
width: 100%;
background-color: black;
text-align: center;
}
.element {
padding: 0.25rem 0.5rem;
color: white;
border: 1px solid white;
}
<div class="wrapper">
<div class="element">Some element</div>
</div>
But it centers the element only horizontally, not vertically.
Are there any ways to solve this problem?

how to remove the margins from the vue site [duplicate]

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;
}

HTML How to draw circle with huge number in exact center? [duplicate]

This question already has answers here:
How can I center text (horizontally and vertically) inside a div block?
(27 answers)
How to draw a circle with text in the middle?
(19 answers)
Closed 2 years ago.
So I am trying to make a single big number like 99 display on a big circle
I've read this and used its code, but the number is not aligned in the exact middle.
here's what I have so far:
.circle {
width: 300px;
height: 300px;
margin-top: 20px;
margin-left: 20px;
border-radius: 50%;
font-size: 200px;
color: #fff;
line-height: 500px;
text-align: center;
background: #000;
}
<div class="circle" id="date">99</div>
You're setting the line height to be more than the area height.
line-height: 300px;
Demo

How to vertically center align a :before element [duplicate]

This question already has answers here:
How can I vertically align elements in a div?
(28 answers)
Vertically align text next to an image?
(26 answers)
How do I vertically align text in a div?
(34 answers)
How to vertically align an image inside a div
(37 answers)
Vertically centering a div inside another div [duplicate]
(24 answers)
Closed 4 years ago.
How do you vertically center align a :before element. I have tried using vertical-align: bottom, vertical-align:middle, vertical-align: -50% and vertical-align:super. Nothing I do is bringing the plus symbol down to be vertically center aligned with the text next to it.
Any ideas?
.infoTitles {
color: #2E393F;
font-family: 'Muli', sans-serif;
font-size: 1.5rem;
line-height: 1.5em;
}
.infoTitles:before {
content: '';
vertical-align: super;
float: left;
margin-right: 8px;
background-image: url('https://cdn4.iconfinder.com/data/icons/ios7-essence/22/add_plus-512.png');
background-size: 15px 15px;
width: 15px;
height: 15px;
display: block;
}
<div class="faqBlock">
<div class="infoTitles">How long will I expect to wait for a quote?</div>
</div>

Text - the block doesnt center align [duplicate]

This question already has answers here:
How can I horizontally center an element?
(133 answers)
Closed 6 years ago.
The whole div remains on left, I tried withe below but no luck
.captionhome {
width: 600px;
padding: 10px;
border: 5px solid black;
margin: 50px;
font-weight: bold;
font-size: 16px;
text-align: center;
}
<div class="captionhome" style="text-align: center;">WARNING: This product contains nicotine. Nicotine is an addictive chemical.</div>
Your captionhome has a set width. Either change that to 100% or add
margin: 0 auto;