CSS adjust brightness of image background and not content - html

The section has a background image with content on top.
I want to decrease the brightness of only the background image in the section and not the content.
I have tried the below, however, the brightness still applies to all and not just the image.
<!-- Section -->
<div id="section1">
<div id="content">
<h1 class="heading">headline text</h1>
<h4 class="subHeading"> Sub-headline text</h4>
<!-- Call to action button -->
<br><br>
<button> Join our wait list </button>
</div>
#section1 {
background: url('../images/headerimage1.jpg') center center no-repeat;
background-size: cover;
-webkit-filter: brightness(0.5);
filter: brightness(0.5);
padding-top: 100px;
padding-bottom: 100px;
padding-left: 10%;
padding-right: 10%;
color: white;
text-align: center;
}
#content {
-webkit-filter: brightness(1);
filter: brightness(1);
}

You can add a new element of transparent black that overlays just the background, with the contents of your div sitting in front of it.
<div id="section1">
<div id="content">
</div>
</div>
CSS:
#section1 {
background: url('../images/headerimage1.jpg') center center no-repeat;
background-size: cover;
position: relative;
}
#content {
position: absolute;
}
#section1::before {
content: '';
display: block;
position: absolute;
background-color: #000;
opacity: 0.5;
width: 100%;
height: 100%;
}

Related

How to Overlay Image on Background in Twitter Bootstrap Section

I have an image that I would like to overlay on top of a background gradient that I have set on a section element. Both the background gradient and image I am setting in CSS and calling via a class in HTML. Originally when just using the background gradient it worked fine, but after adding the image to place over the background gradient the background gradient disappeared?
.banner-gradient {
background: radial-gradient(circle, #ba000b, #9e0008);
color: white;
z-index: 0;
}
.banner-overlay {
background: url("../imagery/image.png");
max-width: 100%;
height: auto;
background-position: bottom;
background-repeat: repeat-x;
z-index: 1;
}
.section-align-center {
text-align: center;
}
<section class="banner-gradient banner-overlay section-align-center">
<div class="container">
<p>image over background gradient</p>
</div>
</section>
Try using background-image instead of background for image.
.banner-gradient:before {
content: " ";
width: 100%;
height: 100%;
position: absolute;
z-index: 1;
top: 0;
left: 0;
background: -webkit-radial-gradient(top center, ellipse cover, rgba(255,255,255,0.2) 0%,rgba(0,0,0,0.5) 100%);
}
.banner-overlay {
background: url('https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png?v=c78bd457575a') repeat;
}
.section-align-center {
height: 400px;
position: relative;
}
<section class="banner-gradient banner-overlay section-align-center">
<div class="container">
<p>image over background gradient</p>
</div>
</section>
I solved this with the help of this post. You must first place the banner-gradient in your outer div then in your inner div use banner-image.
HTML
<section class="banner-gradient section-align-center">
<div class="container banner-overlay">
<p>image over background gradient</p>
</div>
I would rather edit the class of the element you want the transparency in
<div class="background">
<div class="transbox">
<p>This is some text that is placed in the transparent box.</p>
</div>
</div>
div.background {
background: url('https://www.w3schools.com/css/klematis.jpg') repeat;
border: 2px solid black;
}
div.transbox {
margin: 30px;
background-color: #ffffff;
border: 1px solid black;
opacity: 0.6;
filter: alpha(opacity=60); /* For IE8 and earlier */
}
div.transbox p {
margin: 5%;
font-weight: bold;
color: #000000;
}
https://jsfiddle.net/mergatroid/xkmyqjec/1/

Blurring Background image shrinks it, how to blur without it shrinking?

without blur . with blur
I'm a beginners for html,css. I'm trying to blur the background-images for each of my divs, but instead it shrinks it down. How do I go about blurring without it shrinking?
.parallax {
/*height: 500px;*/
height: 100vh;
font-size: 200%;
overflow-x: hidden;
overflow-y: auto;
perspective: 300px;
perspective-origin-x: 100%;
}
.parallax .title {
font-family: 'Lato', sans-serif;
font-weight: bold;
color: #424242 black;
position: absolute;
left: 50%;
top: 50%;
text-align: center;
transform: translate(-50%, -50%);
}
/* below trying to blur */
.parallax .group2 .back {
background: #ffdfba;
background-image: url("image/bubble.png");
background-size:contain;
-webkit-filter: blur(5px);
filter: blur(5px);
height: 500px;
height: 100vh;
}
<div class="group group2">
<div class="layer base">
<div class="title">
Blowing Bubbles are fun! They help calm yourself and give you qualities to breath.
</div>
</div>
<div class="layer back">
<div class="title">
</div>
</div>
</div>
Use background-size: cover for .parallax .group2 .back. The background image will cover the whole div area.
Hope it will help you

How to blur background image of div, without blurring the remaining site or the content of the div

I'm trying to figure out how to blur the background image of a div. The goal is to only blur the background image of the div and not the background of the page itself or the div contents.
Here is an example div:
<header class="intro">
<div class="background-image"></div>
<div class="intro-body">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<h1 class="brand-heading">Grayscale</h1>
<p class="intro-text">A free, responsive, one page Bootstrap theme.
<br>Created by Start Bootstrap.</p>
<a href="#about" class="btn btn-circle page-scroll">
<i class="fa fa-angle-double-down animated"></i>
</a>
</div>
</div>
</div>
</div>
</header>
The CSS:
body {
width: 100%;
height: 100%;
font-family: "Lora", "Helvetica Neue", Helvetica, Arial, sans-serif;
color: white;
background-color: black;
}
.intro {
display: table;
width: 100%;
height: auto;
padding: 100px 0;
text-align: center;
color: white;
}
.intro .background-image {
z-index: 1;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: auto;
background-image: url(https://previews.123rf.com/images/denisovd/denisovd1203/denisovd120301652/12705959-wall-of-wooden-barrels-Stock-Photo-barrels-whiskey-cellar.jpg) no-repeat bottom center scroll;
background-color: black;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);
}
.intro .intro-body {
z-index: 9999;
display: table-cell;
vertical-align: middle;
}
Here is the JS fiddle containing the CSS I've tried:
http://jsfiddle.net/80jzdvqp/
I would high appreciate some help!
Here is the solution
<body><header class="intro">
<div class="background-image"></div>
<div class="intro-body">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<h1 class="brand-heading">Grayscale</h1>
<p class="intro-text">A free, responsive, one page Bootstrap theme.
<br>Created by Start Bootstrap.</p>
<a href="#about" class="btn btn-circle page-scroll">
<i class="fa fa-angle-double-down animated"></i>
</a>
</div>
</div>
</div>
</div>
</header>
</body>
Css :
body {
width: 100%;
height: 100%;
font-family: "Lora", "Helvetica Neue", Helvetica, Arial, sans-serif;
color: white;
background-color: black;
margin: 0;
padding: 0;
}
.intro {
display: table;
width: 100%;
height: auto;
padding: 100px 0;
text-align: center;
color: white;
}
.intro .background-image {
z-index: -1;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: url(https://wallpaperbrowse.com/media/images/html-color-codes-color-tutorials-hero-00e10b1f.jpg);
-webkit-filter: blur(10px);
filter: blur(10px);
}
.intro .intro-body {
z-index: 9999;
display: table-cell;
vertical-align: middle;
}
I have created a example using div, this includes a parent div,image and text. Now if I don't apply any position to elements present inside then they will align one after another, but to make image as background of div I have set it's position as absolute and using filter you can apply blur to the image and then using z-index align them i.e text and image. Hope this helps.
The filter property provides graphical effects like blurring,
sharpening, or color shifting an element. Filters are commonly used to
adjust the rendering of images, backgrounds, and borders.
div{
width:200px;
height:200px;
overflow:hidden;
position:relative;
}
div > img{
width:auto;
height:100%;
z-index:1;
top:0;
left:0;
position:absolute;
filter:blur(10px);
}
div > p{
text-align:center;
top:60px;
z-index:9;
position:relative;
}
<div>
<p>Demo text.Demo text.Demo text.Demo text.Demo text.</p>
<img src="https://previews.123rf.com/images/denisovd/denisovd1203/denisovd120301652/12705959-wall-of-wooden-barrels-Stock-Photo-barrels-whiskey-cellar.jpg">
</div>

Bootstrap Jumbotron Background image Opacity and width and height?

I have the following requirements:
I want the background image of the jumbotron to fit the width of the page and the height to be scaled proportionally
I want the opacity of the jumbotron's background image (only) to be set to a specific value.
My background image is quite large: http://imgur.com/a/qYRGJ
I have tried the following trick recommended somewhere online:
<section class="jumbotron">
<div class="img"></div>
<div class="container">
<div class="row">
<h1 class="display-3">Test</h1>
<p class="lead">Test</p>
<p class="lead">
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
</p>
</div>
</div>
</section>
This is my CSS:
section {
position: relative;
background-color: transparent !important;
}
section .img {
position: absolute;
left:0; top:0;
background-size: cover;
min-height: 768px;
width: 100%;
opacity: 0.45;
background-image: url("1.jpg");
z-index: -1;
}
section .container {
background-color: transparent;
}
section .container .row {
background-color: gray;
padding: 1.5em;
}
Currently, this breaks my code. Creating another after this causes the section to be displayed on the background image.
Can someone recommend a solution that satisfies my requirements?
Works fine if you use this CSS. Overall though, it would be better to edit that photo in Photoshop and set the opacity there rather than doing it in the browser.
<style>
section {
position: relative;
background-color: transparent !important;
}
section .img {
position: absolute;
left:0; top:0;
background-size: cover;
min-height: 768px;
width: 100%;
opacity: 0.45;
background-image: url("http://i.imgur.com/eFMDsVA.jpg");
z-index: -1;
}
section .container {
background-color: transparent;
}
section .container .row {
padding: 1.5em;
}
.jumbotron {
background-color: gray}
</style>

CSS Overlay effect

I'm trying to create overlay effect for a services section. I've managed to get it to cover going from right to left and need to create a few different ones, but can't get it to go from top to bottom or from bottom to the top. Here is an example of the code.
.window-display {
min-height: 500px;
background-image: url('http://loremflickr.com/320/240');
background-size: cover;
background-position: center center;
}
.window-display .heading {
padding-left: 15px;
}
.window-display .overlay {
background-color:rgba(38,37,98,0.8);
min-height: 500px;
width: 40%;
float: right;
overflow: hidden;
-webkit-transition-duration: 2s; /* Safari */
transition-duration: 2s;
}
.window-display:hover .overlay {
width: 100%;
}
<div class="window-display">
<div class="overlay">
<div class="heading">
<h2 style="color: #fff;">SECTION TITLE</h2>
</div>
</div>
</div>
You can use position: absolute on the overlay to achieve the bottom to top and vice versa effect your after.
JSFiddle from bottom to top
JSFiddle from top to bottom
Here's the working code that you can tinker with:
<div class="window-display">
<div class="overlay">
<div class="heading">
<h2>SECTION TITLE</h2>
</div>
</div>
</div>
.window-display {
height: 500px;
background-image: url('http://loremflickr.com/320/240');
background-size: cover;
background-position: center center;
position: relative;
}
.window-display .heading {
padding-left: 15px;
}
.window-display .heading h2 {
color: #fff;
}
.window-display .overlay {
background-color:rgba(38,37,98,0.8);
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height:50px;
-webkit-transition-duration: 2s; /* Safari */
transition-duration: 2s;
}
.window-display:hover .overlay {
height: 100%;
}