I'm currently facing a slight problem with text on top of a 'glass-morphism' effect that is achieved by the backdrop-filter: blur() property. In some cases, the text on top of the div with the glass effect seems a bit blurred or something. This seems to happen when the text jumps to the next line, due to the variable width.
Side-by-side comparisons: https://imgur.com/a/Sq0Unq7.
As you can see, the difference between the viewport width can be as small as 1 pixel. Removing the backdrop-filter fixes the issue, but I'd like to keep it if it's possible. I've tested this in Chrome and Edge (and Internet Explorer, but that doesn't support the backdrop-filter property). Both came out the same.
This is the code for the 'glass' div:
.glassback {
height: auto;
background: rgba(0, 0, 0, 0.55);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
backdrop-filter: blur( 4px );
-webkit-backdrop-filter: blur( 4px );
border-radius: 10px;
padding: 25px;
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
<div class="col-xl-3 col-lg-3 col-md-6 col-12 glassback">
<h3 class="landingpage">FIND YOUR NEW HOME TODAY.</h3>
<br>
<p class="landingpage">We offer a wide variety of apartments and studios in cities like <b>Eindhoven</b>, <b>Tilburg</b> and <b>Arnhem</b>.</p>
<p class="landingpage">Now the real question is:<br>where do <b>you</b> want to live?</p>
<form action="" method="POST">
<div class="row">
<div class="col-10">
<select name="cityselection" id="cityselection" class="form-control overflow">
<option class="overflow" value="all" selected>Eindhoven, Tilburg, Arnhem, 's-Hertogenbosch...</option>
<option value="Eindhoven">Eindhoven</option>
<option value="Tilburg">Tilburg</option>
<option value="Arnhem">Arnhem</option>
<option value="sHertogenbosch">'s-Hertogenbosch</option>
<option value="Amersfoort">Amersfoort</option>
</select>
</div>
<div class="col-2 searchbutton">
<button type="submit" class="btn btn-danger" name="search"><i class="fas fa-search"></i></button>
</div>
</div>
</form>
</div>
Does anyone have any clue? If you need more info, just ask! :)
It's mainly due to the browser engine, and the blurry fonts effect can vary depending of your browser, div size, and even your browser render interpretation. FYI, this behavior also affects div drawings (like a circle having a border radius 100%). Edges can be blurry also in this case.
In all this mess you have a proper workaround: don't apply the backdrop-filter to the div that contains your text, but create a separate absolute div that has the effect, and place it below your text or content. Here is the fix of your code:
<div class="col-xl-3 col-lg-3 col-md-6 col-12 glassback">
<div class="effect"></div>
<h3 class="landingpage">FIND YOUR NEW HOME TODAY.</h3>
<br>
<p class="landingpage">We offer a wide variety of apartments and studios in cities like <b>Eindhoven</b>, <b>Tilburg</b> and <b>Arnhem</b>.</p>
<p class="landingpage">Now the real question is:<br>where do <b>you</b> want to live?</p>
<form action="" method="POST">
<div class="row">
<div class="col-10">
<select name="cityselection" id="cityselection" class="form-control overflow">
<option class="overflow" value="all" selected>Eindhoven, Tilburg, Arnhem, 's-Hertogenbosch...</option>
<option value="Eindhoven">Eindhoven</option>
<option value="Tilburg">Tilburg</option>
<option value="Arnhem">Arnhem</option>
<option value="sHertogenbosch">'s-Hertogenbosch</option>
<option value="Amersfoort">Amersfoort</option>
</select>
</div>
<div class="col-2 searchbutton">
<button type="submit" class="btn btn-danger" name="search"><i class="fas fa-search"></i></button>
</div>
</div>
</form>
</div>
and the css:
.glassback {
height: auto;
background: rgba(0, 0, 0, 0.55);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
border-radius: 10px;
padding: 25px;
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
position: relative;
}
.effect {
backdrop-filter: blur( 4px );
-webkit-backdrop-filter: blur( 4px );
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: -1;
}
And a snippet with a concret example:
body {
background-image: url('https://i.imgur.com/S57AcCZ.png');
background-size: 100%;
background-color: grey;
}
.container {
position: relative;
margin: 20px;
display: flex;
align-items: center;
justify-content: center;
padding: 30px;
color: white;
font-size: 20px;
}
.effect {
backdrop-filter: blur(15px) saturate(100%);
-webkit-backdrop-filter: blur(15px) saturate(100%);
background-color: rgba(39, 39, 39, 0.15);
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: -1;
}
<div class="container">
<div class="effect"></div>
<div class="content">
here is my sharp text
</div>
</div>
Related
I'm trying to build a nice responsive login form with bootstrap but I'm facing an interesting issue.
I would like to make the label to move away from the form input when a text is inside it and I can do that! But the problem is that when I click outside of the login form the label goes back to the middle.
How can I force the transition to persist so that when a text is inside my form the label is kept out of the way?
Here is nice gif with the issue to make it easy visualize
here is the fiddle link: https://jsfiddle.net/d10ayfw5/
body {
margin: auto;
padding-top: 30px;
max-width: 300px;
}
div {
margin: 20px 0 20px 0;
}
.form-outline {
position: relative;
width: 100%;
font-size: 1rem;
font-weight: 400;
transition: all .2s linear;
}
.form-control:active~.form-label {
transform: translateY(-1.5rem) translateY(.1rem) scale(.8);
background-color: rgb(255, 255, 255);
}
.form-control:focus~.form-label {
transform: translateY(-1.5rem) translateY(.1rem) scale(.8);
background-color: rgb(255, 255, 255);
}
.form-control~.form-label {
position: absolute;
top: 0;
left: .75rem;
padding-top: .5rem;
pointer-events: none;
transition: all .2s ease-out;
color: rgba(0, 0, 0, .6);
margin-bottom: auto;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<div class="container d-flex align-items-center">
<div class="row">
<div class="col-md-2">
<form>
<div class="form-outline mb-4">
<input type="email" id="form1Example1" class="form-control" />
<label class="form-label" for="form1Example1">
Email address
</label>
</div>
<div class="form-outline mb-4">
<input type="password" id="form1Example2" class="form-control" />
<label class="form-label" for="form1Example2">Password</label>
</div>
<button type="submit" class="btn btn-primary btn-block">
Sign in
</button>
</form>
</div>
</div>
</div>
First you need to add empty placeholder=' ' to input elements.
So you can use :placeholder-shown pseudo-selector, whether or not they have a value.
Also, from the Selectors spec: Selectors spec
input:not(:placeholder-shown) ~ .form-label {
transform: translateY(-1.5rem) translateY(.1rem) scale(.8);
background-color: rgb(255, 255, 255);
}
this solution is css-only and browser-compatible for majors. can-i-use:placeholder-shown
I want a filter icon which dropup on click and also change icon. In the dropup menu I have checkboxes (They are basically filters). I want dropup to remain open if someone toggle checkboxes but when user click on filter icon (which is now cross icon ) it should close dropup and change its icon back to filter.
I have created drop up and also icon is changed on click, but when someone click on filter menu it closes. I know it is because of toggle function but I don't know how else I can make this work properly.
Also how can I animate this a bit. Would be very appreciative.
.filter {
position: fixed;
left: 20px;
bottom: 40px;
font-size: 40px;
z-index: 1000;
}
.filter-dropup {
position: relative;
display: inline-block;
}
.filter-dropup-content {
display: none;
position: absolute;
bottom: 50px;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
border-radius: 10px;
}
.filter-dropup-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.show {
display: block;
}
<div class="filter">
<div class="filter-dropup">
<i class="fas fa-filter filter-icon"></i>
<div class="filter-dropup-content">
<div>
<input type="checkbox" id="scales" name="scales"
checked>
<label for="scales">Scales</label>
</div>
<div>
<input type="checkbox" id="scales" name="scales"
checked>
<label for="scales">Scales</label>
</div>
<div>
<input type="checkbox" id="scales" name="scales"
checked>
<label for="scales">Scales</label>
</div>
</div>
</div>
$(".filter").click(function () {
$(".filter-icon", this).toggleClass("fas fa-times fas fa-filter");
$(".filter-dropup-content").toggleClass("show", 1000);
});
Here is jsfiddle
First of all, the id and name must be unique, otherwise it always points to the first element that matches the id. I added the handler class to the a label, so that it would work as a button. Sorry about my English, but it's not my native language. jsfiddle I hope I've helped you.
.filter {
position: fixed;
left: 20px;
bottom: 40px;
font-size: 40px;
z-index: 1000;
}
.filter-dropup-content {
display: none;
position: absolute;
bottom: 50px;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
border-radius: 10px;
}
<div class="filter">
<a href="#" class="handler">
<i class="fas fa-filter"></i>
</a>
<div class="filter-dropup-content">
<div>
<input type="checkbox" id="scales" name="scales" checked />
<label for="scales">Scales</label>
</div>
<div>
<input type="checkbox" id="scales_2" name="scales_2" checked />
<label for="scales_2">Scales_2</label>
</div>
<div>
<input type="checkbox" id="scales_3" name="scales_3" checked />
<label for="scales_3">Scales_3</label>
</div>
</div>
</div>
The previous JavaScript closed the menu when you clicked on it, because you were using the .filter container as a button that made everything inside the filter close the menu, since you're using jQuery we can use the fadeToggle function to animate the menu.
$('.handler').on('click', function () {
$(this).find('i').toggleClass('fa-times');
$('.filter-dropup-content').fadeToggle();
});
This is my HTML:
<div class="row trolibelanja">
<div class="col-md-3">
<img src="http://2.bp.blogspot.com/-WGiyrP7xGOk/VQlHwjgporI/AAAAAAAABHI/zLGXTH0-H2w/s1600/Mie%2BAyam%2B(4).jpg" class="detailfoto">
</div>
<div class="col-md-4">
<p class="detailnama">Mie Ayam Bakso</p>
<p class="detailtoko">Toko Bu Lastri</p>
</div>
<div class="col-md-2">
<p class="detailharga">Rp. 30.000</p>
</div>
<div class="col-md-2">
<div class="input-group">
<span class="input-group-btn">
<button class="btnjumlah" type="button">-</button>
</span>
<input type="text" class="form-control jumlah" value="1">
<span class="input-group-btn">
<button class="btnjumlah" type="button">+</button>
</span>
</div>
</div>
<div class="col-md-1">
</div>
</div>
This is my css:
body{
background-color: #661f61 !important;
font-family: 'Saira Extra Condensed', sans-serif !important;
}
.container-fluid.keranjang {
background-color: #e9e9e9;
flex: 1;
}
.container.keranjang {
}
.row.trolibelanja {
background-color: #e1e1e1;
position: relative;
padding-top: 10px;
padding-bottom: 23px;
}
.row.trolibelanja:after{
background-image: -webkit-linear-gradient(135deg, #6e1c64 25%, #e27f31 25%) !important;
position: absolute;
content: " ";
width: 100%;
height: 15px;
bottom: 0;
}
.detailfoto {
width: 100%;
height: 110px;
border: 6px solid white;
}
.detailnama{
font-size: 20px;
font-weight: bold;
}
.detailtoko{
line-height: 20px;
margin: -17px 0px;
}
.detailharga{
font-size: 20px;
font-weight: bold;
text-align: center;
}
.input-group .jumlah {
width: 50%;
text-align: center;
}
.input-group .btnjumlah {
background-color: #e27f31;
color: white;
border: 0;
font-size: 20px;
font-weight: bold;
padding: 0px 10px;
height: 100%;
}
I am trying to put text and form next to photo using bootstrap, as in photo below:
enter image description here
My code result:
enter image description here
Please let me know what am I missing? I tried each combination of display that i know, but they wouldn't work. Thank you
Arrange your columns properly. And you will be good. put image in one column (col-md-3 in this case) and rest of the content in another (col-md-9), then put all rest of the content in a new row. I would suggest that you have a better understanding of the rows and columns from bootstrap website.
https://www.w3schools.com/bootstrap/bootstrap_grid_system.asp
<div class="row trolibelanja">
<div class="col-md-3">
<img src="http://2.bp.blogspot.com/-WGiyrP7xGOk/VQlHwjgporI/AAAAAAAABHI/zLGXTH0-H2w/s1600/Mie%2BAyam%2B(4).jpg" class="detailfoto">
</div>
<div class="col-md-9">
<div class="row">
<div class="col-md-4">
<p class="detailnama">Mie Ayam Bakso</p>
<p class="detailtoko">Toko Bu Lastri</p>
</div>
<div class="col-md-2">
<p class="detailharga">Rp. 30.000</p>
</div>
<div class="col-md-2">
<div class="input-group">
<span class="input-group-btn">
<button class="btnjumlah" type="button">-</button>
</span>
<input type="text" class="form-control jumlah" value="1">
<span class="input-group-btn">
<button class="btnjumlah" type="button">+</button>
</span>
</div>
</div>
</div>
</div>
</div>
Add flex-wrap: nowrap; to your .row.trolibelanja like this:
.row.trolibelanja {
background-color: #e1e1e1;
position: relative;
padding-top: 10px;
padding-bottom: 23px;
flex-wrap: nowrap;
}
I made codepen example with your code: https://codepen.io/anon/pen/wPZoXX
i ran your code on bootsnipp and found everything is placed side by side to each other, except for the fact that you did not add img-responsive to the image class. and that the below code is distorting your design.
.row.trolibelanja:after{
background-image: -webkit-linear-gradient(135deg, #6e1c64 25%, #e27f31 25%) !important;
position: absolute;
content: " ";
width: 100%;
height: 15px;
bottom: 0;
}
dont you what you intent designing with that, but i think you need to run a check that css code .
when i added your css to it, it distort the whole code.
first review your CSS is well written , targeting the right class.
second add img-responsive to the img class and i think you are good
to go.
I have the following code:
<div class="row front-page-img">
<img class="img-responsive" src="http://www.echomountainresort.com/wp-content/uploads/2014/10/echo-mountain-concert_banner_bg.jpg" style="box-shadow: rgba(0,0,0,.2) 3px 5px 5px;">
<div class="front-page-container-search">
<h3>This is the text that I wish could be solid white, but instead it is transparent</h3>
<form>
<div class="input-group">
<input type="text" class="form-control">
<span class="input-group-btn">
<button class="btn btn-default" type="submit">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</form>
</div>
</div>
.front-page-img {
margin-right: 0px;
}
.front-page-container-search{
position:absolute;
left: 50px;
right:50px;
width: 200px;
color: white;
text-align: center;
top: 75px;
background-color: rgba(0, 0, 0, 0.6);
border: 1px solid black;
opacity: 0.7;
margin: 0 auto;
}
As you can see here at my jsFiddle my text is not solid white and my input is transparent. Ideally I would like to have solid white text and a solid input. I attempted to use the accepted answer from this older question and tried playing with z-index, but no luck there. Any help is appreciated.
Set your opacity to 1 and wrap the divs correctly. Here is the fiddle.
https://jsfiddle.net/n6qzsttL/
<div class="row front-page-img ng-scope">
<img class="img-responsive" src="http://www.echomountainresort.com/wp-content/uploads/2014/10/echo-mountain-concert_banner_bg.jpg" style="box-shadow: rgba(0,0,0,.2) 3px 5px 5px;">
<div class="front-page-container-search">
<h3>This is the text that I wish could be solid white, but instead it is transparent</h3>
</div>
<form>
<div class="input-group">
<input type="text" class="form-control"> <span class="input-group-btn">
<button class="btn btn-default" type="submit">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</form>
and the CSS
.front-page-img {
margin-right: 0px;
}
.front-page-container-search {
position:absolute;
left: 50px;
right:50px;
width: 200px;
color: white;
text-align: center;
top: 75px;
background-color: rgba(0, 0, 0, 0.6);
border: 1px solid black;
opacity: 1;
margin: 0 auto;
}
There's nothing wrong with your z-indexes. You're setting the opactiy of .front-page-container-search to 0.7. This does what it says on the tin; it renders the element - including everything inside of it - with an opacity of 0.7.
If you don't want the opacity to propagate through the children, don't set it on the parent. Remove this property, and your text, and input, will be solid white.
Currently you are using the opacity for .front-page-container-search as 0.7. Please use 1 instead of 0.7.
.front-page-container-search{
/* Theoretically for IE 8 & 9 (more valid) */
/* ...but not required as filter works too */
/* should come BEFORE filter */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; // IE8
/* This works in IE 8 & 9 too */
/* ... but also 5, 6, 7 */
filter: alpha(opacity=100); // IE 5-7
/* Modern Browsers */
opacity:1;
}
Before I begin, yes I know this question has been asked many times but I cannot get it to working anyway. I have a div which is transparent but the contents i.e. text and input fields that I dont wan't to be transparent.
Please don't link to previous answers as I followed them but without success.
Here's what my CSS code looks like:
.csmodal {
height: 300px;
width: 600px;
background-color: rgba(25, 11, 36, .5);
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#7F00FF00', EndColorStr='#7F00FF00');
float: none;
display: inline-block;
padding: 30px;
margin: 200px auto;
opacity: 0.4;
}
.cs-container {
margin-right: auto;
margin-left: auto;
}
#cs-headline {
margin-bottom: 20px;
}
#cs-description {
font-size: 14px;
line-height: 20px;
color: #eeee22;
}
h1 {
margin: 10px 0;
text-rendering: optimizelegibility;
color: #eeee22;
}
HTML code:
<div class="cs-container">
<div class="row">
<div class="col-md-6 col-md-offset-3 csmodal">
<h1 id="cs-headline">Website Launching Soon</h1>
<div id="cs-description">
<p style="text-align: center;">The launch of our official website is coming soon. Stay tuned!</p>
</div>
<form class="form-horizontal">
<div class="form-group">
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
</form>
</div>
</div> </div>
Specifying element opacity changes the opacity for the parent and all children.
Thinking in terms of functionality all we want is to be able to see the background. in that case we can apply a background color or an alpha channel like so: background-color:rgba({0 -255},{0 -255},{0 -255},[0 - 1] the last part determines opacity.
In case you want to have an image with an alpha channel you need to have a transparent asset. like so.
Use your imagination if you can position an element in absolute position and apply opacity to that and so on