How to inherit a certain position (CSS) - html

After ~2 hours of researching I couldn't find a solution for my problem, I am trying to inherit the center of the background since the "blurred-box" gets bigger depending on the computer resolution.
It looks like this(laptop resolution):
And I would like to make it show the center of the background image instead of the corner.
* {
margin: 0;
padding: 0;
}
html {
width: 100vw;
height: 100vh;
}
body {
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-position: top;
background-image: url(https://images.unsplash.com/photo-1477346611705-65d1883cee1e?dpr=0.800000011920929&auto=format&fit=crop&w=1199&h=800&q=80&cs=tinysrgb&crop=);
width: 100%;
height: 100%;
font-family: Arial, Helvetica;
letter-spacing: 0.02em;
font-weight: 400;
-webkit-font-smoothing: antialiased;
}
.blurred-box {
position: fixed;
width: 550px;
height: 670px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: inherit;
border-radius: 2px;
overflow: hidden;
}
.blurred-box:after {
content: '';
width: 1000px;
height: 1000px;
background: inherit;
position: absolute;
bottom: 0;
box-shadow: inset 0 0 0 200px rgba(255, 255, 255, 0.05);
filter: blur(10px);
}
.user-login-box {
position: relative;
margin-top: 50px;
text-align: center;
z-index: 1;
}
.user-login-box>* {
display: inline-block;
}
<div class="blurred-box">
<div class="user-login-box">
<h1>text here</h1>
</div>
</div>
If someone posts a solution I would like to have a link for documentation with those informations(if that is okay), thanks.

You are almost good, remove the use of translate() which is creating the issue and center your element using margin:auto instead:
body {
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-position: top;
background-image: url(https://images.unsplash.com/photo-1477346611705-65d1883cee1e?dpr=0.800000011920929&auto=format&fit=crop&w=1199&h=800&q=80&cs=tinysrgb&crop=);
margin:0;
height: 100vh;
font-family: Arial, Helvetica;
letter-spacing: 0.02em;
font-weight: 400;
-webkit-font-smoothing: antialiased;
}
.blurred-box {
position: fixed;
width: 550px;
height: 670px;
top: 0;
left: 0;
bottom:0;
right:0;
margin:auto;
background: inherit;
border-radius: 2px;
overflow: hidden;
}
.blurred-box:after {
content: '';
width: 1000px;
height: 1000px;
background: inherit;
position: absolute;
bottom: 0;
box-shadow: inset 0 0 0 200px rgba(255, 255, 255, 0.05);
filter: blur(10px);
}
.user-login-box {
position: relative;
margin-top: 50px;
text-align: center;
z-index: 1;
}
.user-login-box>* {
display: inline-block;
}
<div class="blurred-box">
<div class="user-login-box">
<h1>text here</h1>
</div>
</div>

Related

I am trying to make 4 stylised cards in html with different positions that display info but they are not formatting correctly

I'm trying to make this in HTML/CSS
Image design in Figma of what I am trying to make
And currently It looks like this
Current way it looks
I am not sure why it is formatting like that and to clarify I haven't made the other 2 cards yet because I was trying to get the first 2 right.
Here is the HTMl code for it (don't mind the class names please)
<div class="v10_8">
<div class="v10_9"></div>
<div class="v10_15">
<div class="v10_14"><span class="v10_10">CAREY</span><span class="v10_11">1</span></div>
<span class="v10_12">On 56 Points</span>
</div>
</div>
<div class="v10_16">
<div class="v10_17"></div>
<div class="v10_18">
<div class="v10_19"><span class="v10_20">STANWAY</span><span class="v10_21">2</span></div>
<div class="v10_40"><span class="v10_22">On 40 Points</span><span class="v10_39">16 points behind Carey</span></div>
</div>
</div>
</div>
And here is the CSS code for it:
width: 262px;
height: 617px;
background: url("../images/v10_23.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 65px;
opacity: 1;
position: relative;
top: 0px;
left: 0px;
overflow: hidden;
}
.v10_8 {
width: 262px;
height: 276px;
background: rgba(255,255,255,1);
opacity: 1;
position: relative;
top: 0px;
left: 0px;
border-top-left-radius: 44px;
border-top-right-radius: 44px;
border-bottom-left-radius: 44px;
border-bottom-right-radius: 44px;
box-shadow: -10.746728897094727px 9.851167678833008px 60px rgba(0, 0, 0, 0.09000000357627869);
overflow: hidden;
}
.v10_9 {
width: 267px;
height: 96px;
background: rgba(248,228,125,1);
opacity: 1;
position: absolute;
top: 180px;
left: 0px;
overflow: hidden;
}
.v10_15 {
width: 135px;
height: 210px;
background: url("../images/v10_15.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 44px;
opacity: 1;
position: absolute;
top: 29px;
left: 65px;
overflow: hidden;
}
.v10_14 {
width: 94px;
height: 138px;
background: url("../images/v10_14.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 17px;
opacity: 1;
position: absolute;
top: 0px;
left: 21px;
overflow: hidden;
}
.v10_10 {
width: 94px;
color: rgba(21,21,21,1);
position: relative;
top: 0px;
left: 0px;
font-family: Folito;
font-weight: Medium;
font-size: 29px;
opacity: 1;
text-align: left;
}
.v10_11 {
width: 30px;
color: rgba(21,21,21,1);
position: absolute;
top: 52px;
left: 32px;
font-family: Folito;
font-weight: Bold;
font-size: 71px;
opacity: 1;
text-align: left;
}
.v10_12 {
width: 135px;
color: rgba(21,21,21,1);
position: absolute;
top: 183px;
left: 0px;
font-family: Folito;
font-weight: Medium;
font-size: 22px;
opacity: 1;
text-align: left;
}
.v10_16 {
width: 262px;
height: 276px;
background: rgba(255,255,255,1);
opacity: 1;
position: absolute;
top: 341px;
left: 1px;
border-top-left-radius: 44px;
border-top-right-radius: 44px;
border-bottom-left-radius: 44px;
border-bottom-right-radius: 44px;
box-shadow: -10.746728897094727px 9.849809646606445px 60px rgba(0, 0, 0, 0.09000000357627869);
overflow: hidden;
}
.v10_17 {
width: 267px;
height: 96px;
background: rgba(119,221,119,1);
opacity: 1;
position: absolute;
top: 180px;
left: 0px;
overflow: hidden;
}
.v10_18 {
width: 167px;
height: 241px;
background: url("../images/v10_18.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 44px;
opacity: 1;
position: absolute;
top: 16px;
left: 50px;
overflow: hidden;
}
.v10_19 {
width: 135px;
height: 138px;
background: url("../images/v10_19.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 17px;
opacity: 1;
position: absolute;
top: 0px;
left: 16px;
overflow: hidden;
}
.v10_20 {
width: 135px;
color: rgba(21,21,21,1);
position: absolute;
top: 0px;
left: 0px;
font-family: Folito;
font-weight: Medium;
font-size: 29px;
opacity: 1;
text-align: left;
}
.v10_21 {
width: 42px;
color: rgba(21,21,21,1);
position: absolute;
top: 52px;
left: 46px;
font-family: Folito;
font-weight: Bold;
font-size: 71px;
opacity: 1;
text-align: left;
}
.v10_40 {
width: 167px;
height: 57px;
background: url("../images/v10_40.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 11px;
opacity: 1;
position: absolute;
top: 183px;
left: 0px;
overflow: hidden;
}
.v10_22 {
width: 137px;
color: rgba(21,21,21,1);
position: absolute;
top: 0px;
left: 15px;
font-family: Folito;
font-weight: Medium;
font-size: 22px;
opacity: 1;
text-align: left;
}
.v10_39 {
width: 167px;
color: rgba(21,21,21,1);
position: absolute;
top: 38px;
left: 0px;
font-family: Folito;
font-weight: Medium;
font-size: 16px;
opacity: 1;
text-align: left;
}
I understand the design may look slightly hard to code but I will try.
I would appreciate it if someone can help me thanks.
Two problems here...
FIRST ONE: The first code of the css you provided is incomplete.
FIRST ONE:
As I looked through your code, I realised you interchanged the positioning of the elements. Use the absolute position on the parent element and relative on the contents of the parent element. If you are a bit confused about the second issue, kindly correct the first mistake and prompt me. I'll help you out.
For this design, you must have a box that contains three columns and have two contents in the left column and the contents in the other columns are in the center.
You can achieve this in minimum div this is example for your single card you can make further changes in it.
.box1_1 {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 262px;
height: 276px;
background: gray;
opacity: 1;
border-radius: 44px;
box-shadow: -10.746728897094727px 9.851167678833008px 60px rgba(0, 0, 0, 0.09000000357627869);
overflow: hidden;
position: relative;
}
.box1_3 {
padding-top: 20%;
font-size: 25px;
font-weight: bold;
text-align: center;
background: red;
height: 100%;
width: 100%;
position: absolute;
top: 10;
}
.box1_2{
font-size: 25px;
font-weight: bold;
text-align: center;
background: yellow;
height: 35%;
width: 100%;
position: absolute;
bottom: 0%;
box-shadow: -10.746728897094727px 9.851167678833008px 60px rgba(0, 0, 0, 0.09000000357627869); /* Add the same box-shadow as the parent container */
}
<div class="box1_1">
<div class="box1_3">
<p>CAREY</p>
<p>1</p>
</div>
<div class="box1_2">
<p>On 56 Points</p>
</div>
</div>

Why margin is not respected in this case?

I can't figure out why a margin is not respected when I resize to mobile view. If you resize the window, left margin is respected, however, right margin is not respected.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.banner-container {
position: relative;
}
.banner-image {
height: 200px;
width: 100%;
background-color: rebeccapurple;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}
.banner-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-width: 560px;
width: 100%;
background-color: rgba(255, 255, 255, 0.5);
text-align: center;
font-size: 32px;
padding: 24px 0;
margin: 0 10px;
}
#media screen and (max-width: 768px) {
.banner-text {
font-size: 24px;
}
}
<div class="banner-container">
<div class="banner-image"></div>
<span class="banner-text">Candidate Membership</span>
</div>
I'd appreciate if someone could explain what I'm doing wrong. Thanks.
The margin is there, but it is added to the 100% width you defined. So the element's width including margins goes beyond the container width.
.banner-text in media width : 80%
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.banner-container {
position: relative;
}
.banner-image {
height: 200px;
width: 100%;
background-color: rebeccapurple;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}
.banner-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-width: 560px;
width: 100%;
background-color: rgba(255, 255, 255, 0.5);
text-align: center;
font-size: 32px;
padding: 24px 0;
margin: 0 10px;
}
#media screen and (max-width: 768px) {
.banner-text {
font-size: 24px;
}
.banner-text{
width: 80%;
}
}
<div class="banner-container">
<div class="banner-image"></div>
<span class="banner-text">Candidate Membership</span>
</div>

Frosted Glass effect: filter: blur()

EDIT: added codepen links
I'm currently attempting to get a frosted glass effect using CSS however everything I've tried has just resulted in a slight tint.
This is being tested in Chrome.
body {
font: 15px/1.5 Arial, Helvetica, sans-serif;
padding: 0;
margin: 0;
background: url("https://i.imgur.com/ht1etAo.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
.frost {
color: #ffffff;
width: 400px;
height: 200px;
position: absolute;
background: inherit;
overflow: hidden;
margin: 0 auto;
padding: 2rem;
}
.frost:before {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: inherit;
filter: blur(20px);
box-shadow: inset 0 0 3000px rgba(255, 255, 255, 0.5);
margin: -20px;
}
<section id="frontImage">
<div class="container">
<div class="frost">
<h3>Testing Glass</h3>
</div>
</div>
</section>
It doesn't actually seem like the filter property is working, as changing it doesn't actually effect the div.
Here's my code: I'm attempting to blur the frost div
Aiming for this kind of effect: https://codepen.io/AmJustSam/full/ModORY/
What I've got: https://codepen.io/anon/pen/PxWEde
I've attempted using webkit-blur too but that hasn't worked either.
Any advice is greatly appreciated. If further info is needed, please ask.
body {
padding: 0;
margin: 0;
background: url("https://i.imgur.com/ht1etAo.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
display: flex;
justify-content: center;
}
.frost {
width: 400px;
height: 200px;
position: absolute;
background: inherit;
}
.frost:before {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
filter: blur(2px);
background: inherit;
}
.content {
position: absolute;
width: 340px;
height: 140px;
top: 30px;
left: 30px;
}
<div class="frost">
<div class="content">
<h3>Testing Glass</h3>
<p>lipsum</p>
</div>
</div>
I think the best way to get a realistic glass effect by using the blurred version of the original image.
Ps: Take it easy guys had an issue with HTML widget.
Here is the code hope that's help
html,
body {
padding: 0;
margin: 0;
}
h2 {
text-align:center;
color:white;
}
.glass-effect--bg-inner {
position:relative;
z-index:1;
padding-top:20px;
}
.container {
width: 100%;
height: 100%;
min-height: 500px;
}
.large-hero--bg {
background: url(https://cdn-std.dprcdn.net/files/acc_609131/p6BW2C) no-repeat fixed;
background-size: cover;
background-position: 50% 0;
}
.glass-effect {
position: relative;
height: 250px;
}
.glass-effect--bg:after {
position: absolute;
top: 0;
left: 0;
z-index: 0;
width: 100%;
height: 100%;
background: url("https://cdn-std.dprcdn.net/files/acc_609131/EElxHZ") repeat fixed;
background-size: cover;
background-position: 50% 0;
content: "";
filter: url("https://cdn-std.dprcdn.net/files/acc_609131/EElxHZ") repeat fixed;
-webkit-filter: blur(5px);
filter: blur(5px);
}
<div class="container large-hero--bg ">
<div class="glass-effect glass-effect--bg">
<div class="glass-effect--bg-inner">
<h2>Lorem ispsum dolor</h2>
</div>
</div>
</div>

Chrome version 62.0.3202.94 3d issue rendering

Can Anyone help me to solve a problem that I found on the last version of Chrome?
I found a problem on Chrome new version regarding the DIV Background in 3D.
In the Chrome versione 61.0.3163.100 the same page was rendered well.
On Safari, Internet Explore, Edge and Firefox the page is rendered without any problem.
I attached in this message just a little part of the original HTML page in order to show which is the problem.
Thanks in advance
Andrea Angeli
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 1.42857143;
color: #333;
background-color: #fff;
}
.container-fluid {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
.corr-container {
text-align: center;
position: relative;
}
.cube {
-moz-perspective: 600px;
perspective: 600px;
-webkit-perspective: 600px;
position: relative;
width: 100%;
display: inline-block;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
}
.cube {
height: 550px;
perspective-origin: 50% 275px;
-webkit-perspective-origin: 50% 275px;
}
.cube-face-top {
left: 0;
width: 100%;
height: 3300px;
transform: rotateX(-90deg);
-webkit-transform: rotateX(-90deg);
transform-origin: center top;
-webkit-transform-origin: center top;
background-image: url(https://www.trulytaly.com/ElementiGrafica/Corridoi/Nuovi/Soffitto.png);
background-size: 100% 550px;
-webkit-background-size: 100% 550px;
}
.cube-face {
position: absolute;
top: 0;
}
.plaza-face-top {
background-repeat: no-repeat;
background-image: url(https://www.trulytaly.com/ElementiGrafica/Piazze/NuoviFilePiazza/CUT-FOTOGALLERIA2-B2-TOP.jpg);
width: 100%;
height: 550px;
background-size: 100% 550px;
position: absolute;
top: 100%;
}
.plaza-face,
.r-plaza-face {
position: absolute;
top: 0;
}
.plaza-face,
.r-plaza-face {
position: absolute;
top: 0;
}
.rplaza-face-top {
background-repeat: no-repeat;
background-image: url(../ElementiGrafica/Piazze/NuoviFilePiazza/CUT-FOTOGALLERIA2-B2-TOP.jpg);
width: 100%;
height: 550px;
background-size: 100% 550px;
position: absolute;
top: -550px;
}
.dropdown-flag {
position: relative;
display: inline-block;
}
.dropdown-content-flag {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
padding: 12px 16px;
}
.dropdown-flag:hover .dropdown-content-flag {
display: block;
}
.col-sx-dx-div-principale {
display: none;
width: 0;
height: 0;
}
#media screen and (min-width: 1900px) {
.div-principale {
max-width: 90%;
position: relative;
float: left;
}
.col-sx-dx-div-principale {
display: block;
position: relative;
float: left;
background-color: white;
transform-style: preserve-3d;
transform: translateZ(20000px);
z-index: 9999999;
height: 900px;
width: 5%;
}
}
}
<div class="div-principale" style="margin: 0 auto; padding: 0;">
<div class="container-fluid" style="padding: 0px;">
<div style="padding-right:0px;padding-left:0px;" class="virtual-container">
<div class="corr-container">
<div class="cube-container">
<div id="cube" data-inverted="false" class="cube" data-p="front">
<div class="cube-face ct cube-face-top">
<div class="pt plaza-face plaza-face-top"></div>
<div class="pt plaza-face rplaza-face-top" style="display:none"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

CSS Background Doesn't Extend to Bottom of Browser

So I have a simple little project I'm making, which has a gradient background. However, upon loading up the website, it looks like this:
image
And, as you can see, it doesn't extend to the bottom of the screen. What is the cause of this? Here is my stylesheet:
* {
box-sizing: border-box;
}
.bg-image {
background-image: url('../bg/bg.png');
background-size: cover;
-webkit-background-size: cover;
display: block;
filter: blur(5px);
-webkit-filter: blur(5px);
height: 800px;
left: 0;
position: fixed;
right: 0;
z-index: -1;
}
.container p {
margin: 1%;
font-weight: bold;
color: #000000;
opacity: 1;
}
.container {
background: rgba(255, 255, 255, 0.35);
border-radius: 3px;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
top: 175px;
left: 0;
position: fixed;
margin-left: 200px;
margin-right: 200px;
right: 0;
padding: 0 10px;
text-align: center;
}
.container ul {
margin: 5%;
font-weight: bold;
color: #000000;
opacity: 1;
}
.container img {
max-width: 600x;
max-height: 400px;
}
.logo img {
margin: 0 auto;
display: block;
max-width: 500px;
max-height: 150px;
}
Thanks for any help.