I'm going straight to the point here.
I want to create a simple window within an image.
outside the window will have a opacity like on the sample picture.
I'm not really good when it comes to css so please bear with me.
.section2{
}
.section2 .row{
margin: 0;
}
.the-container{
position: relative;
width: 100%;
height: 450px;
}
.the-container .text-center{
background: #fff;
opacity: .9;
}
.img-canvas{
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
width: 100%;
height: 100%;
background-image: url(https://www.aman.com/sites/default/files/styles/1371x706/public/amanpulo-location-1200-x-825.jpg?itok=4BQy9j-X);
background-size: 100% 100%;
background-position: 50% 50%;
background-attachment: scroll;
z-index: -1;
}
.window{
position:absolute;
width:50%;
height:50%;
background-size: cover;
top:0;
left:25%;
z-index: -1;
opacity: 1;
}
<section class="section2" style="height:100vh;">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="the-container">
<div class="img-canvas"></div>
<div class="window"></div>
</div>
</div>
</div>
</section>
something like this:
and here's a fiddle for you to manipulate the code:
https://jsfiddle.net/Lk21vL01/
thanks in advance.
You were very close, you just needed to apply similar styling to your .window element and use background-attachment:fixed
see this updated jsfiddle
.section2{
}
.section2 .row{
margin: 0;
}
.the-container{
position: relative;
width: 100%;
height: 450px;
}
.the-container .text-center{
background: #fff;
opacity: .9;
}
.window,
.img-canvas{
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
width: 100%;
height: 100%;
background-image: url(https://www.aman.com/sites/default/files/styles/1371x706/public/amanpulo-location-1200-x-825.jpg?itok=4BQy9j-X);
background-size: 100% 100%;
background-position: 50% 50%;
background-attachment:fixed;
z-index: -1;
opacity: 0.5;
}
.window{
position:absolute;
width:50%;
height:50%;
top:0;
left:25%;
z-index: -1;
opacity: 1;
}
Not the most proper way to achieve this, but you could use a box-shadow "hack" to create the effect you're looking for. Just set a box shadow around the window with 0 blur and a spread that will always bigger than the background (something like 1000, or even 5000 pixels).
#background {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: linear-gradient(to bottom, slategray, #333);
overflow: hidden;
}
#window {
position: absolute;
width: 250px;
height: 100px;
top: 25%;
left: 25%;
box-shadow: 0 0 0 1000px rgba(255, 255, 255, 0.75);
}
<div id="background">
<div id="window">
</div>
</div>
Related
i'm practicing making a web page and i was using boostrap 5. my website is already responsive for mobile devices using the #media but when i try to see my webpage on larger screen sizes some divs - sections - row are out of its place and others remain perfect on their place. How can i make the whole column be center no matter the screen size.
when it's on my resolution it looks perfect
enter image description here
but when i zoom out it moves to the left
enter image description here
HTML
<div class="contaier">
<div class="card">
<div class="row">
<div class="col-12 col-md-8">
<div class="circle"> </div>
<div class="col-6 col-md-4"></div>
<h1>TOKEN</h1>
</div>
<div class="content1">
<p>The token will be launched in phase 2, which will serve as a passive reward for each of our DIVERS and as a token for the metaverse economy that is being built for the third phase.</p>
</div>
<img src="http://luxtopia.org/wp-content/uploads/2022/02/haseowo.gif">
</div>
</div>
</div>
</div>
CSS
* {
padding: 0;
margin: 0;
box-sizing: border-box;
scroll-behavior: smooth;
text-decoration: none;
text-shadow: #000000 0px 0 14px;
}
body{
background-image: url(http://luxtopia.org/wp-content/uploads/2022/03/ffinal.png);
height: 100%;
width: 100%;
background-size: auto;
background-position: bottom center;
font-family: 'Varela', sans-serif;
overflow-x: hidden ;
background-size: 100% 102.5%;
background-attachment: scroll;
background-repeat: no-repeat;
resize: both;
color: var(--font-color);
}
.cards .container{
object-fit: contain;
display:inline-block;
width: 100%;
padding: 1% 15%;
}
.card{
position: relative;
bottom: 850px;
left:230px;
width: 400px;
height: 300px;
background:#335bb7;
border-radius: 100px;
display: flex;
align-items: center;
transition: 0.5s;
border-style: none;
}
.card h1{
position:absolute;
left: 148%;
font-size: 30px;
bottom: 50%;
}
.card2 h1{
position:absolute;
right: 115%;
font-size: 30px;
bottom: 50%;
}
.card3 h1{
position:absolute;
left: 93%;
font-size: 30px;
bottom: 50%;
}
.card4 h1{
position:relative;
right: 46%;
font-size: 30px;
top: 5%;
}
.card .circle{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 20px;
overflow: hidden;
}
.card .circle::before{
content:'';
position: absolute;
top:0;
left:0;
width: 100%;
height: 100%;
background: #335bb7;
clip-path: circle(120px at center);
transition:0.05s;
display:hidden;
}
.card:hover .circle:before
{
background: #00fcf3;
clip-path: circle(400px at center);
height: 250px;
border-radius: 20px;
}
.card img{
position: absolute;
top:50%;
left: 50%;
transform: translate(-50%,-50%);
height: 250px;
width: 250px;
pointer-events: none;
transition:0.05s;
}
.card:hover img{
left: 2%;
top: 35%;
height: 400px;
width: 400px;
}
.card .content1
{
position: absolute;
width: 50%;
left: 10%;
padding:10px 0px 0px 20px;
transition: 0.5s;
opacity: 0;
visibility: hidden;
}
.card:hover .content1
{
left: 0;
opacity: 1;
visibility: visible;
left: 40%;
padding: 65px 20px;
}
thank you all who took the time to read my post, i apreciate any kind of help :')
You have got a typo in your first <div> class-name (contaier -> container).
Add a few flex-attributes:
.card{
justify-content: center;
}
You can alternatively also use the bootstrap classes instead:
<div class="card justify-content-center"></div>
This centers the child-elements of card. In your case: <div class="row">
Not sure if your rows or columns are the problem, since you only posted a snippet of your code. If you have trouble with the centering of your columns, just add this bootstrap class to the respective div: <div class="row justify-content-center">
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>
How to create a partial width opacity ?
I have a div that has a background image with transparency, I used after to do get the effect like this
.indicators-menu {
width: 100%;
height: 100%;
display: block;
position: absolute;
top: 0;
z-index: 1;
}
.indicators-menu::after {
background-image: url('bg_platform_repeat.jpg');
content: "";
opacity: 0.9;
top: 0;
position: absolute;
z-index: -1;
left: 0;
width: 100%;
height: 100%;
background-repeat: no-repeat;
background-size: cover;
background-position: unset;
}
This works great, but what I need to do is to split the opacity by width
instead of 100% to 80% with opacity 0.9 and 20% with opacity 1
I thought to use the CSS mask property but I see that its not well supported
what i need to do is to split the opacity by width instead of 100% to 80% with opacity 0.9 and 20% with opacity 1
Use two pseudo-elements with the same background image but position them differently.
div {
width: 460px;
height: 300px;
margin: 1em auto;
border: 1px solid red;
position: relative;
}
div:before,
div:after {
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 0;
background-image: url(http://www.fillmurray.com/460/300);
background-repeat: no-repeat;
background-size: cover;
}
div:before {
width: 80%;
opacity: 0.5;
/* for example */
}
div:after {
width: 20%;
left: 80%;
background-position: 100% 0;
}
<div>
</div>
One idea is to use an overlay above the image to simulate this effect. The color used need to be the same as the below background:
.box {
background:
linear-gradient(rgba(255,255,255,0.3),rgba(255,255,255,0.3)) left/80% 100%,
url('https://picsum.photos/200/200?image=1069') center/cover;
background-repeat: no-repeat;
width: 200px;
height: 200px;
}
<div class="box">
</div>
Use :before with background: white; and opacity:0.1(I set 0.4 only you to see the difference) and width:80%
.indicators-menu::after,.indicators-menu::before{
background-image: url('https://i.imgur.com/BK7wL0d.jpg');
content: "";
opacity:1;
top: 0;
position: absolute;
z-index: -1;
left: 0;
width: 100%;
height: 100%;
background-repeat: no-repeat;
background-size: cover;
background-position: unset;
}
.indicators-menu::before{
background: white;
opacity: 0.4;
z-index: 2;
width: 80%;
}
<div class="indicators-menu">
</div>
I have created a code for setting up sketch style borders over image.
Which can be seen below:
jQuery('.border').click(function(){
jQuery('.border').toggleClass('resize');
});
body {
background-color: lightblue;
}
.border {
width: 200px;
margin: 0px auto;
position: relative;
-webkit-transition: all 2s;
/* Safari */
transition: all 2s;
background-image: url(https://nosycrow.com/wp-content/themes/nosy-crow/images/borders/black-400-sides.png);
background-repeat: repeat-y;
background-size: 100%;
border-radius: 15px;
background-position: 0 0;
padding: 5px;
overflow: hidden;
}
.border .padding::before, .border .padding::after {
content: '';
display: block;
position: absolute;
left: 0;
width: 100%;
height: 0;
background: url(https://nosycrow.com/wp-content/themes/nosy-crow/images/borders/black-400.png) no-repeat;
background-size: 100%;
z-index: 50;
padding-bottom: 5.4%;
pointer-events: none;
}
.border .padding::before {
top: 0px;
}
.border .padding::after {
bottom: 0px;
background-position: 0px 100%;
}
.border.resize {
width: 500px;
}
img {
width: 100%;
height: auto;
position: relative;
border-radius: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="border">
<div class="padding">
<img src="https://nosycrow.com/wp-content/uploads/imported-books/Spectre-Collectors-Too-Ghoul-For-School-312087-3-593x911.jpg" alt="">
</div>
</div>
But the issue is, the box is not accurately responsive. To test it out, I have added a little jquery script so when you click on the image, the image resizes. And you can see when the image is bigger, the borders doesn't look aligned properly.
I know in my solution, to fix this I have to add media queries so the borders on top and borders can be adjusted in media queries. But is there any better solution then that?
I got it fixed using different solution. Kind of old school. I used 3 images, horizontal line, vertical line and corner and used them to set up in their position using different divs. Can be seen here
jQuery('.sketchy-box').click(function(){
jQuery('.sketchy-box').toggleClass('resize');
});
.sketchy-box {
width: 300px;
height: auto;
margin: 0px auto;
position: relative;
-webkit-transition: all 1s;
/* Safari */
transition: all 1s;
}
.sketchy-box .bdt {
position: absolute;
z-index: 1;
left: 10px;
top: 0px;
width: calc(100% - 20px);
height: 5px;
background: url("http://aslamdoctor.com/taskapp/horizontal-stroke#4x-100.svg") left top repeat-x;
}
.sketchy-box .bdb {
position: absolute;
z-index: 1;
left: 10px;
bottom: 0px;
width: calc(100% - 20px);
height: 5px;
background: url("http://aslamdoctor.com/taskapp/horizontal-stroke#4x-100.svg") left top repeat-x;
transform: rotate(180deg);
}
.sketchy-box .bdl {
position: absolute;
z-index: 1;
left: 0px;
top: 10px;
width: 5px;
height: calc(100% - 20px);
background: url("http://aslamdoctor.com/taskapp/vertical-stroke#4x-100.svg") left top repeat-y;
transform: rotate(180deg);
}
.sketchy-box .bdr {
position: absolute;
z-index: 1;
right: 0px;
top: 10px;
width: 5px;
height: calc(100% - 20px);
background: url("http://aslamdoctor.com/taskapp/vertical-stroke#4x-100.svg") left top repeat-y;
}
.sketchy-box .corner {
position: absolute;
z-index: 1;
width: 13px;
height: 13px;
background: url("http://aslamdoctor.com/taskapp/corner-stroke#4x-100.svg") left top no-repeat;
}
.sketchy-box .ctl {
left: 0px;
top: 0px;
}
.sketchy-box .ctr {
right: 0px;
top: 0px;
transform: rotate(90deg);
}
.sketchy-box .cbl {
left: 0px;
bottom: 0px;
transform: rotate(-90deg);
}
.sketchy-box .cbr {
right: 0px;
bottom: 0px;
transform: rotate(180deg);
}
.sketchy-box img {
width: 100%;
height: auto;
position: relative;
z-index: 0;
border-radius: 10px;
}
.sketchy-box.resize {
width: 1000px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="sketchy-box">
<div class="bdl"></div>
<div class="bdr"></div>
<div class="bdt"></div>
<div class="bdb"></div>
<div class="corner ctl"></div>
<div class="corner ctr"></div>
<div class="corner cbl"></div>
<div class="corner cbr"></div>
<img src="https://nosycrow.com/wp-content/uploads/2015/09/BooksAlways_26-27-593x320.jpg" alt="">
</div>
From this jsfiddle: http://jsfiddle.net/vbaWK/3/, how can I make the fixed overlayed black rectangle appear over the blue rectangle, where they both overlap while scrolling the body. There is an added rule though, whereever there is no overlap, it should be over everything, including the overlay. Thanks.
html:
<div class="black"></div>
<div class="blue"></div>
<div class="green"></div>
<div class="overlay"></div>
css:
.black
{
background: black;
width: 100px;
height: 100px;
position: fixed;
top: 0;
left: 0;
z-index: -1;
}
.blue
{
background: blue;
width: 100px;
height: 2000px;
z-index: 4;
position: relative;
}
.green
{
background: green;
width:100px;
height: 2000px;
z-index: 2;
position: relative;
}
.overlay
{
background: white;
opacity: 0.8;
height: 100%;
width: 100%;
position: fixed;
top: 0;
left: 0;
z-index:3;
}
Thanks for any help.
Sorry I forgot to mention that when the blue rectangle is not overlapping, it should be over the overlay. There is a conflict.
Give the black rectangle the highest possible z-index, something like this:
.black
{
background: black;
width: 100px;
height: 100px;
position: fixed;
top: 0;
left: 0;
z-index: 999;
}