Why background gradient pushing content down? - html

I have a class called bgGradient which adds a gradient. When .bgGradient is added, it's pushing my content down a considerable amount, whereas I basically just want it as the background.
.content {
padding: 100px 0px;
border: 1px solid blue;
}
.bgGradient {
border: 1px solid red;
height: 100vh;
width: 100vw;
padding: 0;
margin: 0;
position: absolute;
background: rgb(92, 156, 155);
background: -moz-linear-gradient(90deg, rgba(92, 156, 155, 1) 0%, rgba(140, 205, 204, 1) 100%);
background: -webkit-linear-gradient(90deg, rgba(92, 156, 155, 1) 0%, rgba(140, 205, 204, 1) 100%);
background: linear-gradient(90deg, rgba(92, 156, 155, 1) 0%, rgba(140, 205, 204, 1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#5c9c9b", endColorstr="#8ccdcc", GradientType=1);
}
.bgGradient:before {
content: '';
display: block;
width: 0;
height: 0;
border-style: solid;
border-width: 100vh 0 0 100vw;
border-color: #fff transparent #fff transparent;
z-index: 2;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="wrapper bgGradient">
<div class="container">
<div class="row justify-content-center">
<div class="col-6 content text-center">
<h2>this is a test heading</h2>
</div>
</div>
</div>
</div>

No need extra element, you can consider multiple background:
.content {
padding: 100px 0px;
border: 1px solid blue;
}
.bgGradient {
border: 1px solid red;
height: 100vh;
left:0;
right:0;
padding: 0;
margin: 0;
position: absolute;
background:
linear-gradient(to bottom left,#fff 49.7%,transparent 50%),
linear-gradient(90deg, rgba(92, 156, 155, 1) 0%, rgba(140, 205, 204, 1) 100%);
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" >
<div class="wrapper bgGradient">
<div class="container">
<div class="row justify-content-center">
<div class="col-6 content text-center">
<h2>this is a test heading</h2>
</div>
</div>
</div>
</div>
You can also have transparency using clip-path:
.content {
padding: 100px 0px;
border: 1px solid blue;
}
.bgGradient {
border: 1px solid red;
height: 100vh;
left:0;
right:0;
padding: 0;
margin: 0;
position: absolute;
z-index:0;
}
.bgGradient:before {
content:"";
position: absolute;
z-index:-1;
top:0;left:0;right:0;bottom:0;
background:
linear-gradient(90deg, rgba(92, 156, 155, 1) 0%, rgba(140, 205, 204, 1) 100%);
clip-path:polygon(0 0,0 100%,100% 100%);
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" >
<div class="wrapper bgGradient">
<div class="container">
<div class="row justify-content-center">
<div class="col-6 content text-center">
<h2>this is a test heading</h2>
</div>
</div>
</div>
</div>
Or mask-image:
.content {
padding: 100px 0px;
border: 1px solid blue;
}
.bgGradient {
border: 1px solid red;
height: 100vh;
left:0;
right:0;
padding: 0;
margin: 0;
position: absolute;
z-index:0;
}
.bgGradient:before {
content:"";
position: absolute;
z-index:-1;
top:0;left:0;right:0;bottom:0;
background:
linear-gradient(90deg, rgba(92, 156, 155, 1) 0%, rgba(140, 205, 204, 1) 100%);
-webkit-mask-image:linear-gradient(to bottom left,transparent 49.8%,#fff 50%);
mask-image:linear-gradient(to bottom left,transparent 49.8%,#fff 50%);
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" >
<div class="wrapper bgGradient">
<div class="container">
<div class="row justify-content-center">
<div class="col-6 content text-center">
<h2>this is a test heading</h2>
</div>
</div>
</div>
</div>

Related

How to remove white lines of card-img in an img-overlay card?

I'm making a web page with some cards in a row with multiple columns using Bootstrap 4.5, but there are white lines in the borders (?) of the card-img I can't remove:
In the CSS you can observe I'm using padding at card-img, trying to determine whether those are border lines or something else, but I don't understand their "parent".
<div class="row row-flex d-flex row-black align-items-stretch">
<div class="col-md-6 col-xl-4 card-col">
<div class="card border-dark">
<img class="card-img grad-bg1" aria-hidden="true">
<div class="card-img-overlay">
<h1 class="text-center"><i class="fa fa-flask text-light" aria-hidden="true"></i></h1>
<h3 class="card-title">Flask!</h3>
<h5 class="card-text text-center">It's a lab!</h5>
</div>
</div>
</div>
</div>
The CSS is
.row-black {
background-color: #000;
color: #fff;
min-height: 286px;
padding-top: 1.61%;
padding-bottom: 1.61%;
padding-left: 6.85% !important;
padding-right: 6.85% !important;
align-items: center;
justify-content: center;
}
.card-col {
margin-top: 1.61%;
margin-bottom: 1.61%;
}
.card {
background-color: transparent !important;
border-radius: 30px;
min-height: 350px;
height: 100%;
max-height: 350px;
border: none !important;
background: transparent;
}
.card-img {
border-radius: 30px;
height: 100%;
border: none !important;
margin: 0;
padding: 10px;
}
.card-img-overlay {
height: 100%;
width: 100%;
padding: 50px;
align-items: center;
justify-items: center;
border: none !important;
}
.card-title {
text-align: center;
border: none;
}
.grad-bg1 {
background: -moz-linear-gradient(135deg, rgba(60, 176, 219, 1) 0%, rgba(6, 26, 85, 1) 100%);
background: -webkit-linear-gradient(135deg, rgba(60, 176, 219, 1) 0%, rgba(6, 26, 85, 1) 100%);
background: linear-gradient(135deg, rgba(60, 176, 219, 1) 0%, rgba(6, 26, 85, 1) 100%);
height: 100%;
width: 100%;
border: none !important;
}
that "border" comes from the missing src attribute on your image tag.
You can achieve what you need without it or you can simply add a src to the image tag.
HTML
<div class="row row-flex d-flex row-black align-items-stretch">
<div class="col-md-6 col-xl-4 card-col">
<div class="card border-dark">
<div class="card-img-overlay grad-bg1">
<h1 class="text-center">
<i class="fa fa-flask text-light" aria-hidden="true"></i>
</h1>
<h3 class="card-title">Flask!</h3>
<h5 class="card-text text-center">It's a lab!</h5>
</div>
</div>
</div>
</div>
CSS
.row-black {
background-color: #000;
color: #fff;
min-height: 286px;
padding-top: 1.61%;
padding-bottom: 1.61%;
padding-left: 6.85% !important;
padding-right: 6.85% !important;
align-items: center;
justify-content: center;
}
.card-col {
margin-top: 1.61%;
margin-bottom: 1.61%;
}
.card {
background-color: transparent !important;
border-radius: 30px;
min-height: 350px;
height: 100%;
max-height: 350px;
border: none !important;
background: transparent;
}
.card-img-overlay {
height: 100%;
width: 100%;
padding: 50px;
align-items: center;
justify-items: center;
border: none !important;
}
.card-title {
text-align: center;
border: none;
}
.grad-bg1 {
background: -moz-linear-gradient(
135deg,
rgba(60, 176, 219, 1) 0%,
rgba(6, 26, 85, 1) 100%
);
background: -webkit-linear-gradient(
135deg,
rgba(60, 176, 219, 1) 0%,
rgba(6, 26, 85, 1) 100%
);
background: linear-gradient(
135deg,
rgba(60, 176, 219, 1) 0%,
rgba(6, 26, 85, 1) 100%
);
height: 100%;
width: 100%;
border: none !important;
border-radius: 30px;
}
Demo
https://codepen.io/vagelisp/pen/yLaeMVg

Dropdown Menu Element Not Displaying

I'm making a website that uses a group of images as a menu.
I was able to get one side to properly display the dropdown (slideout, in this case) menus. But even though both sides are identical, the other one does not display the menu on mouseOver.
I looked through the code for the last hour, and just can't find what is wrong.
Here is the jsFiddle.
Thanks :)
* {
box-sizing: border-box;
}
h1 {
font-size: 50px;
color: aliceblue
}
.topbar{
margin-top: 0px;
padding: 1px;
background-color:#605E5E;
border-bottom-style:inset;
border-bottom-color: #888888;
}
.touch-menu{
/* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#eda954+0,e5933b+29,e59f54+56,e89230+79,e89230+91,e89230+100 */
background: rgb(237,169,84); /* Old browsers */
background: -moz-linear-gradient(top, rgba(237,169,84,1) 0%, rgba(229,147,59,1) 29%, rgba(229,159,84,1) 56%, rgba(232,146,48,1) 79%, rgba(232,146,48,1) 91%, rgba(232,146,48,1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(237,169,84,1) 0%,rgba(229,147,59,1) 29%,rgba(229,159,84,1) 56%,rgba(232,146,48,1) 79%,rgba(232,146,48,1) 91%,rgba(232,146,48,1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(237,169,84,1) 0%,rgba(229,147,59,1) 29%,rgba(229,159,84,1) 56%,rgba(232,146,48,1) 79%,rgba(232,146,48,1) 91%,rgba(232,146,48,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eda954', endColorstr='#e89230',GradientType=0 ); /* IE6-9 */
display: flex;
padding: 10px;
}
ul {
text-align: center;
list-style-type: none;
margin: 10px;
vertical-align: middle;
}
.slideout-content-top-left, .slideout-content-bottom-left {
display: none;
height: 95%;
margin: 10px 0px 10px 0px;
min-width: 16px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
background-color: #736E6F;
z-index: 1;
}
.slideout-content-top-right, .slideout-content-bottom-right {
display: none;
height: 95%;
margin: 10px 10px 10px 0px;
background-color: #736E6F;
min-width: 16px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
vertical-align: middle;
}
.menu-top-right :hover + .slideout-content-top-right , .menu-bottom-right :hover + .slideout-content-bottom-right {
display: inline-block;
}
.slideout-content-bottom-right:hover , .slideout-content-top-right:hover {
display: inline-block;
}
.menu-top-left :hover + .slideout-content-top-left , .menu-bottom-left :hover + .slideout-content-bottom-left {
display: inline-block;
}
.slideout-content-bottom-left:hover , .slideout-content-bottom-left:hover {
display: inline-block;
}
.touch-menu img:hover {
filter: brightness(1.25);
}
.column {
flex: 50%;
display: flex;
flex-direction: column;
vertical-align: middle;
}
.menu-top-left , .menu-bottom-left , .menu-bottom-right, .menu-top-right {
flex: 50%;
height: 100%;
}
.menu-bottom-left img, .menu-top-left img{
width: 50%;
height: 95%;
float: right;
margin: 10px 10px 10px 0px;
}
.menu-bottom-right img , .menu-top-right img {
width: 50%;
height: 95%;
float: left;
margin: 10px 0px 10px 10px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Heter Iska</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="images/favicon.png">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="css/styles.css">
<style>
body {font-family: "Lato", sans-serif}
</style>
</head>
<body>
<header>
<div class="topbar" align="center">
<h1>Links of Links</h1>
</div>
</header>
<div class="touch-menu" align="center">
<div class="column slideout-left" align="right">
<div class="menu-top-left" >
<div class="slideout-content-top-left" id="top-left">
<ul>
<li>
scaleLink 1
</li>
<li>
scaleLink 2
</li>
<li>
scaleLink 3
</li>
</ul>
</div>
<img class="slideout" src="https://avatarfiles.alphacoders.com/105/thumb-105223.jpg" alt="scale">
</div>
<div class="menu-bottom-left" >
<div class="slideout-content-bottom-left" id="bottom-left">
<ul>
<li>
bookLink 1
</li>
<li>
bookLink 2
</li>
<li>
bookLink 3
</li>
</ul>
</div>
<img class="slideout " src="https://avatarfiles.alphacoders.com/105/thumb-105223.jpg" alt="Book" >
</div>
</div>
<div class="column slideout-right" align="left">
<div class= "menu-top-right">
<img class="slideout " src="https://avatarfiles.alphacoders.com/105/thumb-105223.jpg" alt="topGavel">
<div class="slideout-content-top-right" id="top-right" >
<ul class="slidelist">
<li>
ugavelLink 1
</li>
<li>
ugavelLink 2
</li>
<li>
ugavelLink 3
</li>
</ul>
</div>
</div>
<div class="menu-bottom-right">
<img class="slideout" src="https://avatarfiles.alphacoders.com/105/thumb-105223.jpg" alt="bottomGavel">
<div class="slideout-content-bottom-right" id="bottom-right">
<ul>
<li>
lgavelLink 1
</li>
<li>
lgavelLink 2
</li>
<li>
lgavelLink 3
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Footer -->
<footer class="w3-container w3-padding-2 w3-center w3-opacity w3-dark-grey w3-xlarge">
<p class="w3-medium">Powered by Barack Obama</p>
</footer>
<script>
function expandTab(n) {
document.getElemen
}
</script>
</body>
</html>
Your css is wrong. You are using + instead >
* {
box-sizing: border-box;
}
h1 {
font-size: 50px;
color: aliceblue
}
.topbar {
margin-top: 0px;
padding: 1px;
background-color: #605E5E;
border-bottom-style: inset;
border-bottom-color: #888888;
}
.touch-menu {
/* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#eda954+0,e5933b+29,e59f54+56,e89230+79,e89230+91,e89230+100 */
background: rgb(237, 169, 84); /* Old browsers */
background: -moz-linear-gradient(top, rgba(237, 169, 84, 1) 0%, rgba(229, 147, 59, 1) 29%, rgba(229, 159, 84, 1) 56%, rgba(232, 146, 48, 1) 79%, rgba(232, 146, 48, 1) 91%, rgba(232, 146, 48, 1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(237, 169, 84, 1) 0%, rgba(229, 147, 59, 1) 29%, rgba(229, 159, 84, 1) 56%, rgba(232, 146, 48, 1) 79%, rgba(232, 146, 48, 1) 91%, rgba(232, 146, 48, 1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(237, 169, 84, 1) 0%, rgba(229, 147, 59, 1) 29%, rgba(229, 159, 84, 1) 56%, rgba(232, 146, 48, 1) 79%, rgba(232, 146, 48, 1) 91%, rgba(232, 146, 48, 1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eda954', endColorstr='#e89230', GradientType=0); /* IE6-9 */
display: flex;
padding: 10px;
}
ul {
text-align: center;
list-style-type: none;
margin: 10px;
vertical-align: middle;
}
.slideout-content-top-left, .slideout-content-bottom-left {
display: none;
height: 95%;
margin: 10px 0px 10px 0px;
min-width: 16px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
background-color: #736E6F;
z-index: 1;
}
.slideout-content-top-right, .slideout-content-bottom-right {
display: none;
height: 95%;
margin: 10px 10px 10px 0px;
background-color: #736E6F;
min-width: 16px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
vertical-align: middle;
}
.menu-top-right:hover > .slideout-content-top-right, .menu-bottom-right:hover > .slideout-content-bottom-right {
display: inline-block;
}
.slideout-content-bottom-right:hover, .slideout-content-top-right:hover {
display: inline-block;
}
.menu-top-left:hover > .slideout-content-top-left, .menu-bottom-left:hover > .slideout-content-bottom-left {
display: inline-block;
}
.slideout-content-bottom-left:hover, .slideout-content-bottom-left:hover {
display: inline-block;
}
.touch-menu img:hover {
filter: brightness(1.25);
}
.column {
flex: 50%;
display: flex;
flex-direction: column;
vertical-align: middle;
}
.menu-top-left, .menu-bottom-left, .menu-bottom-right, .menu-top-right {
flex: 50%;
height: 100%;
}
.menu-bottom-left img, .menu-top-left img {
width: 50%;
height: 95%;
float: right;
margin: 10px 10px 10px 0px;
}
.menu-bottom-right img, .menu-top-right img {
width: 50%;
height: 95%;
float: left;
margin: 10px 0px 10px 10px;
}

How to center 4 absolute-divs (balls) in the middle of my screen?

I am trying to create a loading-screen effect for my current assignment.
It requires us to create a <div class="overlay"> with position: fixed. This funds as the background. Withing this div, there are 4 <div class="circle"> with position: absolute.
We have to center these using absolute-position and transform: translate. and each ball has a margin of 80px inbetween them
Here is an image of an example I try to re-create
I have managed so far to perfectly-center the balls, but cause of the position: absolute they all overlap. How can I make sure I can get all 4 balls like in the picture?
html {
scroll-behavior: smooth;
}
body {
z-index: 0;
background-color: #fff;
}
.overlay {
background-color: #0d1133;
position: fixed;
top: 0;
left: 0;
z-index: 1;
height: 100vh;
width: 100vw;
}
.circle {
width: 80px;
height: 80px;
background: #fff;
display: inline-block;
border-radius: 40px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#yellow {
background-color: linear-gradient(180deg, rgba(248, 255, 0, 1) 0%, rgba(255, 145, 0, 1) 50%, rgba(255, 145, 0, 1) 100%);
}
#red {
background: linear-gradient(180deg, rgba(255, 0, 215, 1) 0%, rgba(255, 0, 61, 1) 50%, rgba(255, 0, 0, 1) 100%);
}
#blue {
background: linear-gradient(180deg, rgba(0, 255, 243, 1) 0%, rgba(0, 224, 255, 1) 50%, rgba(0, 185, 255, 1) 100%);
}
#purple {
background: linear-gradient(180deg, rgba(255, 0, 241, 1) 0%, rgba(222, 0, 255, 1) 50%, rgba(157, 0, 255, 1) 100%);
}
<main>
<div class="overlay">
<div class="circle" id="yellow"></div>
<div class="circle" id="red"></div>
<div class="circle" id="blue"> </div>
<div class="circle" id="purple"></div>
</div>
</main>
You can wrap them inside a wrapper class and position that div absolute (like you did for each ball).
html {
scroll-behavior: smooth;
}
body {
z-index: 0;
background-color: #fff;
}
.overlay {
background-color: #0d1133;
position: fixed;
top: 0;
left: 0;
z-index: 1;
height: 100vh;
width: 100vw;
}
.wrapper {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%)
}
.circle {
width: 80px;
height: 80px;
background: #fff;
display: inline-block;
border-radius: 40px;
}
#yellow {
background-color: linear-gradient(180deg, rgba(248, 255, 0, 1) 0%, rgba(255, 145, 0, 1) 50%, rgba(255, 145, 0, 1) 100%);
}
#red {
background: linear-gradient(180deg, rgba(255, 0, 215, 1) 0%, rgba(255, 0, 61, 1) 50%, rgba(255, 0, 0, 1) 100%);
}
#blue {
background: linear-gradient(180deg, rgba(0, 255, 243, 1) 0%, rgba(0, 224, 255, 1) 50%, rgba(0, 185, 255, 1) 100%);
}
#purple {
background: linear-gradient(180deg, rgba(255, 0, 241, 1) 0%, rgba(222, 0, 255, 1) 50%, rgba(157, 0, 255, 1) 100%);
}
<main>
<div class="overlay">
<div class="wrapper">
<div class="circle" id="yellow"></div>
<div class="circle" id="red"></div>
<div class="circle" id="blue"> </div>
<div class="circle" id="purple"></div>
</div>
</div>
</main>
I would go with flexboxes, but if you need to animate them using transform: translate you can position them using:
transform: translate(calc(-50% + <OFFSET>px), -50%)
html {
scroll-behavior: smooth;
}
body {
z-index: 0;
background-color: #fff;
}
.overlay {
background-color: #0d1133;
position: fixed;
top: 0;
left: 0;
z-index: 1;
height: 100vh;
width: 100vw;
}
.circle {
width: 80px;
height: 80px;
background: #fff;
display: inline-block;
border-radius: 40px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#yellow {
background-color: linear-gradient(180deg, rgba(248, 255, 0, 1) 0%, rgba(255, 145, 0, 1) 50%, rgba(255, 145, 0, 1) 100%);
transform: translate(calc(-50% - 240px), -50%);
}
#red {
background: linear-gradient(180deg, rgba(255, 0, 215, 1) 0%, rgba(255, 0, 61, 1) 50%, rgba(255, 0, 0, 1) 100%);
transform: translate(calc(-50% - 80px), -50%);
}
#blue {
background: linear-gradient(180deg, rgba(0, 255, 243, 1) 0%, rgba(0, 224, 255, 1) 50%, rgba(0, 185, 255, 1) 100%);
transform: translate(calc(-50% + 80px), -50%);
}
#purple {
background: linear-gradient(180deg, rgba(255, 0, 241, 1) 0%, rgba(222, 0, 255, 1) 50%, rgba(157, 0, 255, 1) 100%);
transform: translate(calc(-50% + 240px), -50%);
}
<main>
<div class="overlay">
<div class="circle" id="yellow"></div>
<div class="circle" id="red"></div>
<div class="circle" id="blue"> </div>
<div class="circle" id="purple"></div>
</div>
</main>
You could use display: flex, aswell as align-items and justify content on the parent like so :
html {
scroll-behavior: smooth;
}
body {
z-index: 0;
background-color: #fff;
}
.overlay {
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
align-items: center;
background-color: #0d1133;
position: fixed;
top: 0;
left: 0;
z-index: 1;
height: 100vh;
width: 100vw;
}
.circle {
width: 80px;
height: 80px;
background: #fff;
display: inline-block;
border-radius: 40px;
}
#yellow {
background-color: linear-gradient(180deg, rgba(248, 255, 0, 1) 0%, rgba(255, 145, 0, 1) 50%, rgba(255, 145, 0, 1) 100%);
}
#red {
background: linear-gradient(180deg, rgba(255, 0, 215, 1) 0%, rgba(255, 0, 61, 1) 50%, rgba(255, 0, 0, 1) 100%);
}
#blue {
background: linear-gradient(180deg, rgba(0, 255, 243, 1) 0%, rgba(0, 224, 255, 1) 50%, rgba(0, 185, 255, 1) 100%);
}
#purple {
background: linear-gradient(180deg, rgba(255, 0, 241, 1) 0%, rgba(222, 0, 255, 1) 50%, rgba(157, 0, 255, 1) 100%);
}
<main>
<div class="overlay">
<div class="circle" id="yellow"></div>
<div class="circle" id="red"></div>
<div class="circle" id="blue"> </div>
<div class="circle" id="purple"></div>
</div>
</main>
Add an absolutely-positioned div container around the circles, and centre this on the page.
Then put the circles inside it (no longer absolutely-positioned) and give them a margin.
html {
scroll-behavior: smooth;
}
body {
z-index: 0;
background-color: #fff;
}
.overlay {
background-color: #0d1133;
position: fixed;
top: 0;
left: 0;
z-index: 1;
height: 100vh;
width: 100vw;
}
.circles-container {
width: 100%;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.circle {
width: 30px;
height: 30px;
background: #fff;
margin: 30px;
display: inline-block;
border-radius: 40px;
transform: translate(-50%, -50%);
}
#yellow {
background-color: linear-gradient(180deg, rgba(248, 255, 0, 1) 0%, rgba(255, 145, 0, 1) 50%, rgba(255, 145, 0, 1) 100%);
}
#red {
background: linear-gradient(180deg, rgba(255, 0, 215, 1) 0%, rgba(255, 0, 61, 1) 50%, rgba(255, 0, 0, 1) 100%);
}
#blue {
background: linear-gradient(180deg, rgba(0, 255, 243, 1) 0%, rgba(0, 224, 255, 1) 50%, rgba(0, 185, 255, 1) 100%);
}
#purple {
background: linear-gradient(180deg, rgba(255, 0, 241, 1) 0%, rgba(222, 0, 255, 1) 50%, rgba(157, 0, 255, 1) 100%);
}
<main>
<div class="overlay">
<div class="circles-container">
<div class="circle" id="yellow"></div>
<div class="circle" id="red"></div>
<div class="circle" id="blue"> </div>
<div class="circle" id="purple"></div>
</div>
</div>
</main>
This is perfect and clean code using css flex
Html Code:
<div class="circles-container">
<div class="circle" id="red"></div>
<div class="circle" id="orange"></div>
<div class="circle" id="green"> </div>
<div class="circle" id="purple"></div>
</div>
</div>
Css Code:
.main-div{
width:100%;
height:-webkit-fill-available;
display:flex;
background: navy;
justify-content: center;
flex-direction: column;
align-items: center;
}
.circle{
width:10px;
height:10px;
border-radius:50px;
display:inline-block;
}
#red{
background:red
}
#orange{
background:orange;
}
#green{
background:green;
}
#purple{
background:purple;
}

drop - down menu in css

I am new in css/html . I am working on cctccart project.while running this code
in bottom_menu,during click any menu like Products ,white background color is merging with blue.I want to fix this problem
HTML
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Welcome to Cctvcart store</title>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<div class="header_wrap">
<div class="header_top_wrap">
<div class="header_top">
</div>
</div>
<!--end of header top wrap -->
<div class="header_bottom_wrap">
<div class="header_bottom">
<ul class="bottom_menu">
<li>Company
</li>
<li>Products
<u1 class="submenu">
<li>DVR & Kits
</li>
<li>spy camraes
</li>
<li>alarms
</li>
</u1>
</li>
<li>Services
</li>
<li>Support
</li>
<li>Multimedia
</li>
</ul>
</div>
</div>
<!--end of bottom wrap -->
</div>
<!--end of header wrap -->
<div class="main_wrap">
<div class="main">
</div>
<!--end of main -->
</div>
<!--end of main wrap -->
<div class="footer_wrap">
<footer></footer>
</div>
<!--end of footer wrap -->
</body>
</html>
CSS
* {
margin: 0px;
padding: 0px;
}
.header_wrap {
width: 100%;
height: 160px;
background: red;
position: relative;
}
.main_wrap {
width: 100%;
height: 1475px;
background: green;
}
.footer_wrap {
width: 100%;
height: 325px;
background: aqua;
}
.main {
width: 1000px;
height: 100%;
background: blue;
margin: auto;
}
footer {
width: 1000px;
height: 100%;
background: aqua;
margin: auto;
}
.header_top_wrap {
width: 100%;
height: 23px;
background: #ccc;
}
.header_bottom_wrap {
width: 100%;
height: 40px;
background: #06F;
position: absolute;
bottom: 0px;
left: 0px;
}
.header_top {
width: 1000px;
height: 100%;
background: purple;
margin: auto;
}
.header_bottom {
width: 1000px;
height: 100%;
background: black;
margin: auto;
}
.bottom_menu > li {
display: inline-block;
}
.bottom_menu a
{
font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", "Arial Black", sans-serif;
color: #fff;
}
.bottom_menu > li >a {
display: block;
text-decoration: none;
padding: 0px 30px;
height: 45px;
line-height: 35px;
text-align: center;
}
.bottom_menu > li:hover >a
{
background:#fff;
color:#151716;
}
.submenu a:active, .submenu a:visited{
display: block;
color: #fff;
text-decoration: none;
z-index: 21;
}
.submenu {
position: absolute;
display: none;
width:160px;
height:250px;
background:white;
list-style:none;
}
.dropdown:hover > .submenu{
display: block;
}
.submenu>li>a
{
display:block;
width:100%;
height:42px;
background:black;
text-decoration:none;
line-height:58px;
padding-left:50px;
border:1px dashed white;
}
Edit your CSS to this:
.bottom_menu > li >a {
display: block;
text-decoration: none;
padding: 0px 30px;
height: 40px; /* this is the thing you have to fix */
line-height: 35px;
text-align: center;
}
I hope it can help you.
Link
HTML
<form id="form1" runat="server">
<div>
<br />
<br />
<div style="text-align: center;">
<label class="button">
<input type="radio" name="button" />
<span class="outer"><span class="inner"></span></span><span class="text">Add Details</span></label>
<label class="button">
<input type="radio" name="button" /> <span class="outer"><span class="inner"></span></span><span class="text">Choice 2</span></label>
<br />
<br />
<br />
<br />
</div>
<br />
</div>
</form>
CSS
.button {
background: #cfe7fa;
background: -moz-linear-gradient(top, #cfe7fa 0%, #6393c1 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #cfe7fa), color-stop(100%, #6393c1));
background: -webkit-linear-gradient(top, #cfe7fa 0%, #6393c1 100%);
background: -o-linear-gradient(top, #cfe7fa 0%, #6393c1 100%);
background: -ms-linear-gradient(top, #cfe7fa 0%, #6393c1 100%);
background: linear-gradient(top, #cfe7fa 0%, #6393c1 100%);
border: 1px solid #6393c1;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
-moz-box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .5), inset -1px -1px 0 rgba(0, 0, 0, .5);
-webkit-box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .5), inset -1px -1px 0 rgba(0, 0, 0, .5);
box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .5), inset -1px -1px 0 rgba(0, 0, 0, .5);
cursor: pointer;
display: inline-block;
font: 10px Arial, Verdana, Geneva, sans-serif;
line-height: 3px;
padding-right: 5px;
}
.button:hover .inner {
opacity:.5;
}
.button input {
display:none;
}
.button input:checked + .outer .inner {
opacity:1;
}
.button .outer {
background:#2989d8;
background:-moz-radial-gradient(center, ellipse cover, #2989d8 0%, #101354 99%);
background:-webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, #2989d8), color-stop(99%, #101354));
background:-webkit-radial-gradient(center, ellipse cover, #2989d8 0%, #101354 99%);
background:-o-radial-gradient(center, ellipse cover, #2989d8 0%, #101354 99%);
background:-ms-radial-gradient(center, ellipse cover, #2989d8 0%, #101354 99%);
background:radial-gradient(center, ellipse cover, #2989d8 0%, #101354 99%);
border:1px solid black;
-moz-border-radius:10px;
-webkit-border-radius:10px;
border-radius:10px;
height:10px;
margin:5px;
width:10px;
}
.button .inner {
background:#e4f5fc;
background:-moz-radial-gradient(center, ellipse cover, #e4f5fc 0%, #bfe8f9 50%, #9fd8ef 51%, #2ab0ed 100%);
background:-webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, #e4f5fc), color-stop(50%, #bfe8f9), color-stop(51%, #9fd8ef), color-stop(100%, #2ab0ed));
background:-webkit-radial-gradient(center, ellipse cover, #e4f5fc 0%, #bfe8f9 50%, #9fd8ef 51%, #2ab0ed 100%);
background:-o-radial-gradient(center, ellipse cover, #e4f5fc 0%, #bfe8f9 50%, #9fd8ef 51%, #2ab0ed 100%);
background:-ms-radial-gradient(center, ellipse cover, #e4f5fc 0%, #bfe8f9 50%, #9fd8ef 51%, #2ab0ed 100%);
background:radial-gradient(center, ellipse cover, #e4f5fc 0%, #bfe8f9 50%, #9fd8ef 51%, #2ab0ed 100%);
-moz-border-radius:10px;
-webkit-border-radius:10px;
border-radius:10px;
display:block;
height:10px;
margin:.5px;
opacity:0;
-moz-transition:opacity .5s;
-webkit-transition:opacity .5s;
-o-transition:opacity .5s;
transition:opacity .5s;
width:10px;
}
span.text,
span.outer
{
display: inline-block;
vertical-align: middle;
}

CSS with IPhone Chat layout

I'm trying to create a page wich will be used to send/receive SMS, I want to show when each SMS was sent/received but I can't seem to be able to align the date right...
Here is my jsfiddle: https://jsfiddle.net/xazvruqj/2/
EDIT: My jsfiddle was missing the actual CSS ...
This part in my CSS is causing me trouble :
.dateR{
position: absolute;
width: 400px;
float: left;
top: 100%;
text-align: right;
font-size: 75%;
font-style: italic;
}
.dateL{
position: absolute;
width: 200px;
left: 2px;
top: 100%;
text-align: left;
font-size: 75%;
font-style: italic;
}
As you can see the dates on the right are completly wrong, I would like them to be text-aligned to the right and under the message.
I thougth that using position:absolute for the date would make it easier but it was only true for the left side.
Thanks for reading this.
There are probably other solutions out there - but it's easy enough if you just place the dates in their own containers and align them separately.
Here's a solution using a new CSS class "bubble-line":
/* Bit of normalisation */
body {
background-color: #eee;
color: #222;
font: 0.8125em/1.5'Helvetica Neue', Helvetica, Arial, sans-serif;
width: 400px;
}
img {
display: block;
height: auto;
max-width: 100%;
}
.container {
padding: 10px 10px;
margin: 0 auto;
width: 400px;
}
/* .bubble */
.bubble-line {
width: 100%;
position: relative;
}
.bubble-line-right {
width: 100%;
float: right;
}
.bubble {
background-image: linear-gradient(bottom, rgb(210, 244, 254) 25%, rgb(149, 194, 253) 100%);
background-image: -o-linear-gradient(bottom, rgb(210, 244, 254) 25%, rgb(149, 194, 253) 100%);
background-image: -moz-linear-gradient(bottom, rgb(210, 244, 254) 25%, rgb(149, 194, 253) 100%);
background-image: -webkit-linear-gradient(bottom, rgb(210, 244, 254) 25%, rgb(149, 194, 253) 100%);
background-image: -ms-linear-gradient(bottom, rgb(210, 244, 254) 25%, rgb(149, 194, 253) 100%);
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.25, rgb(210, 244, 254)), color-stop(1, rgb(149, 194, 253)));
border: solid 1px rgba(0, 0, 0, 0.5);
/* vendor rules */
border-radius: 20px;
/* vendor rules */
box-shadow: inset 0 5px 5px rgba(255, 255, 255, 0.4), 0 1px 3px rgba(0, 0, 0, 0.2);
/* vendor rules */
box-sizing: border-box;
clear: both;
margin-bottom: 5px;
padding: 8px 30px;
position: relative;
display: inline-block;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
width: auto;
max-width: 100%;
word-wrap: break-word;
}
.bubble:before,
.bubble:after {
border-radius: 20px / 10px;
content: '';
display: block;
position: absolute;
}
.bubble:before {
border: 10px solid transparent;
border-bottom-color: rgba(0, 0, 0, 0.5);
bottom: 0;
left: -7px;
z-index: -2;
}
.bubble:after {
border: 8px solid transparent;
border-bottom-color: #d2f4fe;
bottom: 1px;
left: -5px;
}
.bubble--alt {
background-image: linear-gradient(bottom, rgb(172, 228, 75) 25%, rgb(122, 205, 71) 100%);
background-image: -o-linear-gradient(bottom, rgb(172, 228, 75) 25%, rgb(122, 205, 71) 100%);
background-image: -moz-linear-gradient(bottom, rgb(172, 228, 75) 25%, rgb(122, 205, 71) 100%);
background-image: -webkit-linear-gradient(bottom, rgb(172, 228, 75) 25%, rgb(122, 205, 71) 100%);
background-image: -ms-linear-gradient(bottom, rgb(172, 228, 75) 25%, rgb(122, 205, 71) 100%);
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.25, rgb(172, 228, 75)), color-stop(1, rgb(122, 205, 71)));
float: right;
display: inline-block;
}
.bubble--alt:before {
border-bottom-color: rgba(0, 0, 0, 0.5);
border-radius: 20px / 10px;
left: auto;
right: -7px;
}
.bubble--alt:after {
border-bottom-color: #ace44b;
border-radius: 20px / 10px;
left: auto;
right: -5px;
}
.dateR {
display: inline-block;
float: right;
text-align: right;
font-size: 75%;
font-style: italic;
}
.dateL {
text-align: left;
font-size: 75%;
font-style: italic;
}
<body>
<div class="container">
<div class="bubble-line">
<div class="bubble ">Test</div>
</div>
<div class="bubble-line">
<div class="dateL">11 mai 2015 12:02:02</div>
</div>
<div class="bubble-line">
<div class="bubble bubble--alt">Test</div>
</div>
<div class="bubble-line-right">
<div class="dateR">12 mai 2015 12:02:02</div>
</div>
<div class="bubble-line">
<div class="bubble bubble--alt">TestTestTestTestTest TestTest Test Test TestTestTestTestTestTestTest</div>
</div>
<div class="bubble-line-right">
<div class="dateR">12 mai 2015 12:02:02</div>
</div>
<div class="bubble-line">
<div class="bubble ">TestTestTestTestTest TestTest Test Test TestTestTestTestTestTestTest</div>
</div>
<div class="bubble-line">
<div class="dateL">12 mai 2015 12:02:02</div>
</div>
</div>
</body>
<body>
<div class="container">
<div class="bubble-line">
<div class="bubble ">Test</div>
</div>
<div class="bubble-line">
<div class="dateL">11 mai 2015 12:02:02</div>
</div>
<div class="bubble-line">
<div class="bubble bubble--alt">Test</div>
</div>
<div class="bubble-line-right">
<div class="dateR">12 mai 2015 12:02:02</div>
</div>
<div class="bubble-line">
<div class="bubble bubble--alt">TestTestTestTestTest TestTest Test Test TestTestTestTestTestTestTest</div>
</div>
<div class="bubble-line-right">
<div class="dateR">12 mai 2015 12:02:02</div>
</div>
<div class="bubble-line">
<div class="bubble ">TestTestTestTestTest TestTest Test Test TestTestTestTestTestTestTest</div>
</div>
<div class="bubble-line">
<div class="dateL">12 mai 2015 12:02:02</div>
</div>
</div>
</body>
That way, you don't run into issues with floats stacking up on the same line, and don't break the background image positions on the text bubbles.
Hi not sure if this will help.
Use on your .dateR
position:absolute;
left: 0; (Or wherever you want it)
No need for float:left with absolute positioning
Also, make sure the parent element is set to position:relative;