Control display of DIV after CSS mask on sibling DIV background - html

Am sure that I am doing something stupid, but cannot figure out how to get the contents of a DIV to fully render in front of another DIV that has a masked background.
See sample here: https://jsfiddle.net/pLwbsqjv/
What I am trying to do is to get the circle to fully display in front of the green circle that is a masked background.
The only constraint is that the circle with the number in it cannot be positioned absolutely as needs to have its width / height set on a % basis, eg: percentage of the outer container.
Anyone tell me what I am doing wrong?!
Thanks
body {
background: #252526;
}
.ontop {
margin: -50% 0 0 0;
border-radius: 50%;
width: 22%;
height: 22%;
padding: 10px;
background: rgb(34, 51, 68, .5);
border: 2px solid #def;
color: #def;
text-align: center;
font: 30px Arial, sans-serif;
}
.bounds {
width: 200px;
height: 200px;
}
.color-circle {
-webkit-mask: url('https://perlmaven.com/img/circle.svg') no-repeat center;
mask: url('https://perlmaven.com/img/circle.svg') no-repeat center;
background-color: #26bf75;
background-position: center;
background-repeat: no-repeat;
background-size: contain;
width: 100%;
height: 100%;
}
.bottom {
height: 80%;
width: 100%;
}
<div id="bounds" class="bounds">
<div class="bottom">
<div class="color-circle"></div>
</div>
<div class="ontop">01</div>
</div>

You can add position: relative and z-index to .ontop:
body {
margin: 0;
background: #252526;
}
.ontop {
position: relative;
z-index: 1;
margin: -50% 0 0 0;
border-radius: 50%;
width: 22%;
height: 22%;
padding: 10px;
background: rgb(34, 51, 68, .5);
border: 2px solid #def;
color: #def;
text-align: center;
font: 30px Arial, sans-serif;
}
.bounds {
width: 200px;
height: 200px;
}
.color-circle {
-webkit-mask: url('https://perlmaven.com/img/circle.svg') no-repeat center;
mask: url('https://perlmaven.com/img/circle.svg') no-repeat center;
background-color: #26bf75;
background-position: center;
background-repeat: no-repeat;
background-size: contain;
width: 100%;
height: 100%;
}
.bottom {
height: 80%;
width: 100%;
}
<div id="bounds" class="bounds">
<div class="bottom">
<div class="color-circle"></div>
</div>
<div class="ontop">01</div>
</div>
Note:
Regarding this comment:
The only constraint is that the circle with the number in it cannot be
positioned absolutely as needs to have its width / height set on a %
basis, eg: percentage of the outer container.
Position absolute would have worked as well. You need to designate the container for the absolutely positioned element. To do so, the container must have any position that is not static. In this example I've added position relative to .bounds:
body {
margin: 0;
background: #252526;
}
.ontop {
position: absolute;
z-index: 1;
margin: -50% 0 0 0;
border-radius: 50%;
width: 22%;
height: 22%;
padding: 10px;
background: rgb(34, 51, 68, .5);
border: 2px solid #def;
color: #def;
text-align: center;
font: 30px Arial, sans-serif;
}
.bounds {
position: relative; /** this sets the container **/
width: 200px;
height: 200px;
}
.color-circle {
-webkit-mask: url('https://perlmaven.com/img/circle.svg') no-repeat center;
mask: url('https://perlmaven.com/img/circle.svg') no-repeat center;
background-color: #26bf75;
background-position: center;
background-repeat: no-repeat;
background-size: contain;
width: 100%;
height: 100%;
}
.bottom {
height: 80%;
width: 100%;
}
<div id="bounds" class="bounds">
<div class="bottom">
<div class="color-circle"></div>
</div>
<div class="ontop">01</div>
</div>

Related

how do i get this background image to be in the center of the header?

header {
background-image: url('tiredBOX.jpg');
border: solid 3px orange;
height: 200px;
width: 200px;
border-radius: 50%;
padding: 30px;
}
}
h1 {
text-align: center;
color: orange;
background-color: lightgrey;
border: dotted white 4px;
margin-right: 600px;
margin-left: 600px
}
body {
background-color: teal;
}
have i gone about this wrong or is there a simple bit of code to get the background image and border etc into the center of the header area?
You can use margin: auto; under the header.
To center background Image:
background-position: center;
header {
background: url(https://images.pexels.com/photos/210205/pexels-photo-210205.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1) center center no-repeat;
border: solid 3px orange;
height: 200px;
width: 200px;
border-radius: 50%;
padding: 30px;
}
h1 {
text-align: center;
color: orange;
background-color: lightgrey;
border: dotted white 4px;
/* margin-right: 600px;
margin-left: 600px;*/
}
body {
background-color: teal;
}
<header>
<h1>Answer</h1>
</header>
try:
background-size: contain; // or cover depending on your preference
background-repeat: no-repeat;
background-position: center center;

How to style a blurred, centered and responsive box for a login form with full size background?

I have tried to build a login form on a HTML page (Angular) that has a full size, centered background image and the form is placed in a div with blurred background, that is centered in the x- and y-axis of the browser window.
That is how far I came: https://codepen.io/surfermicha/pen/ZwpxBa
<div class="login-background-door2">
<div class="aero-background centered">
<h3>Here will be a login form later</h3>
</div>
</div>
Unfortunately i have some issues with that:
The centered box isn't exactly in the center
It's not responsive. The div is to small at small devices. I want 10px margin left and right, but a max-width 500px on bigger screens.
Could anyone help edit the codepen for a working responsive solution
You can set media queries by your needs, like I set into 567px because after 567px view of your center block, don't look nice so I set into 567px.
body, html {
font-family: "roboto", monospace;
color: #EEE;
padding: 0;
width: 100%;
margin: 0;
height: 100%;
overflow-x: hidden;
}
.aero-background::before {
content: '';
background: url("http://placekitten.com/2400/2000") center no-repeat;
filter: blur(6px);
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: -1;
pointer-events: none;
}
.aero-background {
border-radius: 5px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
border: 1px solid rgba(255, 255, 255, 0.1);
color: white;
align-items: center;
justify-content: center;
text-shadow: 0 0 10px black;
}
.centered {
max-width: 500px;
min-height: 300px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.login-background-door2 {
background: url("http://placekitten.com/2400/2000") center no-repeat;
height: 100%;
width: 100%;
overflow: hidden;
}
#media screen and (max-width: 567px) {
.centered {
width: 250px;
}
}
<div class="login-background-door2">
<div class="aero-background centered">
<h3>Here will be a login form later</h3>
</div>
</div>
https://codepen.io/anon/pen/MLjXgW
Centered with flex, no media queries
body, html {
font-family: "roboto", monospace;
color: #EEE;
padding: 0;
width: 100vw;
margin: 0;
height: 100vh;
overflow-x: hidden;
}
$login-background-image: "http://placekitten.com/2400/2000";
.aero-background::before{
content: '';
background: url($login-background-image) center no-repeat;
filter: blur(6px);
position: absolute;
left:0; top:0; right:0; bottom:0;
z-index: -1;
pointer-events: none;
}
.aero-background {
border-radius:5px;
box-shadow: 0 0 15px rgba(black, .4);
border:1px solid rgba(white,.1);
color: white;
align-items: center;
justify-content: center;
text-shadow:0 0 10px black;
max-width:500px;
min-height: 300px;
margin-left: 10px;
margin-right: 10px;
display: flex;
text-align: center;
padding: 10px;
}
.login-background-door2 {
background: url($login-background-image) center no-repeat;
height: 100%;
width: 100%;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
<div class="login-background-door2">
<div class="aero-background">
<h3>Here will be a login form later</h3>
</div>
</div>
My first time answering so I apologize if missed something

parallax scrolling pages arranged oddly

I want the about div to show up BELOW the
full screen home card
I'm having troubles getting it to show like it should.
my html code has both divs in the "right" order and when i look it up online, i couldn't find any solutions.
<body>
<div class="homeCard">
<div class="homeCardTitle">
<h1>Robin Riezebos</h1>
</div>
</div>
<div class="aboutCard">
<div class="aboutCardText">
<h2>About</h2>
</div>
</div>
</body>
my css is either missing something or I did something completely wrong but I can't seem to find out what it is so please help...
index.css
.homeCard {
background-image: url("images/helicopter-in-sky-2.jpg");
height: 100%;
width: 100%;
position: fixed;
float: left;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
z-index: 0;
}
.homeCardTitle {
position: fixed;
width: 100%;
height: 320px;
top: 50%;
margin-top: -160px;
color: white;
text-shadow: 0 0 10px black;
}
.aboutCard {
background-color: #1F1F1F;
color: white;
height: 500px;
}
Please change your css like below, i think the problem was with position fixed, if you want to get your background image rendered fully please respective pixels of height.
.homeCard {
background-image: url("images/helicopter-in-sky-2.jpg");
width: 100%;
position: relative;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
z-index: 0;
}
.homeCardTitle {
color: white;
text-shadow: 0 0 10px black;
}
.aboutCard {
background-color: #1F1F1F;
color: white;
height: 500px;
}
I have found a solution by bugging around in my css.
Turns out in stead of position: fixed; I should have used background-attachment: fixed; and remove position all-together.
this is my own fixed code:
.homeCard {
background-image: url("images/helicopter-in-sky-2.jpg");
height: 100%;
width: 100%;
background-attachment: fixed;
float: left;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
z-index: 0;
}
.homeCardTitle {
position: relative;
width: 100%;
height: 0px;
top: 50%;
margin-top: -90px;
color: white;
text-shadow: 0 0 10px black;
}
.aboutCard {
width: 100%;
background-color: #1F1F1F;
color: white;
height: 320px;
float: left;
text-align: center;
}

ParticleJS is not allowing clicks though its running on the background

I have a simple page in which I want particle js animation at the background and have a button and few anchors for user to click. However, when I add particle js to a particular div, which is parent, I am not able to click the button or the anchors. I did try changing the z-index of them to higher number(z-index:2000), that didn't help either.
This is the code:
https://plnkr.co/edit/JMYVXu6I3G7kdKUWN7tc?p=preview
/* Styles go here */
body{
color:white;
}
#home {
color:white;
padding-bottom: 2em;
min-height: 100vh;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
background-image: url("http://www.melbourne.vic.gov.au/SiteCollectionImages/1200-buildings-898x381.jpg");
/* fallback */
background-image: linear-gradient(to bottom, rgba(0, 67, 105, 0.5) 0%, rgba(0, 67, 105, 0.5) 100%), url("http://www.melbourne.vic.gov.au/SiteCollectionImages/1200-buildings-898x381.jpg"g);
}
.home-icon {
width: 2em;
height: 2em;
text-align: center;
margin: 0.5em;
font-size: 2em;
color: #f5f5f5;
border: 2px solid #f5f5f5;
border-radius: 50%;
padding: 0.5em;
transition: all .5s ease;
z-index:1040
}
.home-icon:hover {
border: 2px solid #00B9DA;
color: #00B9DA;
}
.particles-js-canvas-el {
top: -200px;
position: relative;
height: 200px;
}
This should resolve your issue:
HTML:
<!-- particles.js container -->
<div id="particles-js">
<div class="test">AAA</div>
</div>
CSS:
canvas {
index: 0;
display: block;
vertical-align: bottom;
}
.test {
index: 50;
top: 100px;
position: absolute;
}
#particles-js {
position: absolute;
width: 100%;
height: 100%;
background-color: #b61924;
background-image: url("");
background-repeat: no-repeat;
background-size: cover;
background-position: 50% 50%;
}}

I want this <p> tag to come bottom of the image?

I am totally new to this html/css I am trying to do float a text with background as image .Yes I did that but the problem is the text is floating on top of the image.If use margin-top to adjust the image,it just simple pull down the whole div.Here down i gave a pictorial representation of what I want.
html
<div class="maincon">
<div class="picon" style="background-image: linear-gradient(to bottom, rgba(0, 0, 0, .02), rgba(0, 0, 0, .8)), url('img/apple.jpg') "><p>Hi</p>
</div>
</div>
Css
.maincon {
margin-top: 95px;
width: 80%;
margin-left: auto;
margin-right: auto;
height: 100%;
}
.picon {
width: 100%;
height: 80%;
background: none center/cover #f2f2f2;
}
.picon p {
}
You can use position: absolute
.element {
height: 100vh;
background:linear-gradient(to bottom, rgba(0, 0, 0, .02), rgba(0, 0, 0, .8)), url('http://cdn2.macworld.co.uk/cmsdata/features/3598128/iphone_6s_review_20.jpg');
background-size: cover;
position: relative;
}
p {
position: absolute;
color: white;
font-size: 25px;
margin: 10px;
bottom: 0;
}
<div class="element">
<p>Apple iphone</p>
</div>
wihtout position absolute and relative .you can use flexbox module.it supports all latest browsers.
.element {
height: 80vh;
background: linear-gradient(to bottom, rgba(0, 0, 0, .02), rgba(0, 0, 0, .8)), url('http://cdn2.macworld.co.uk/cmsdata/features/3598128/iphone_6s_review_20.jpg');
background-size: cover;
align-items: flex-end;
display: flex;
}
p {
color: white;
font-size: 25px;
margin: 10px;
}
<div class="element">
<p>Apple iphone</p>
</div>
.maincon {
margin-top: 95px;
width: 80%;
margin-left: auto;
margin-right: auto;
height: 100%;
}
.picon {
width: 100%;
height: 80%;
background: none center/cover #f2f2f2;
position: relative;
}
.picon p {
position: absolute;
bottom: 0;
}