This question already has answers here:
How to apply a CSS filter to a background image
(22 answers)
Closed 16 days ago.
I am new to this type of code and wanted to grayscale the background image without effecting the overlay text
HTML CODE
<div class="top">
<div class="titleMain">
<div class="titleMainText">
<h1>Check out our Store</h1>
</div>
Shop
</div>
</div>
CSS CODE
.top {
padding-bottom: 500px;
padding-top: 50px;
border-bottom: 10px solid;
background-image: url('../Images/46162.webp');
background-repeat: no-repeat;
background-size: cover;
}
.titleMain {
margin-left: 5%;
margin-right: 70%;
margin-top: 5%;
padding-bottom: 40px;
font-size: xx-large;
filter: none;
}
.titleMainText {
margin-left: 10px;
padding-top: 10px;
padding-bottom: 10px;
font-weight: bolder;
color: black;
}
I wanted to grayscale the background image without effecting the text infront but can't find anything about it.
you can use the filter property to make your background grayscale and use before pseudo before property to apply grayscale without affecting
overlay text.
Just add filter property to the below class in your CSS:
.top {
position: relative;
padding-bottom: 500px;
padding-top: 50px;
border-bottom: 10px solid;
}
.top::before{
content: "";
position: absolute;
top: 0; left: 0;
width: 100%; height: 100%;
filter: grayscale(100%);
background-image: url('../Images/46162.webp');
background-repeat: no-repeat;
background-size: cover;
z-index: -1;
}
Try this:
.top {
padding-bottom: 500px;
padding-top: 50px;
border-bottom: 10px solid;
background-image: linear-gradient(black, white),url('https://lumiere-a.akamaihd.net/v1/images/sa_pixar_virtualbg_coco_16x9_9ccd7110.jpeg?region=0,0,1920,1080&width=1200');
background-repeat: no-repeat;
background-size: cover;
background-blend-mode: saturation;
}
.titleMain {
margin-left: 5%;
margin-right: 70%;
margin-top: 5%;
padding-bottom: 40px;
font-size: xx-large;
filter: none;
}
.titleMainText {
margin-left: 10px;
padding-top: 10px;
padding-bottom: 10px;
font-weight: bolder;
color: black;
}
<div class="top">
<div class="titleMain">
<div class="titleMainText">
<h1>Check out our Store</h1>
</div>
Shop
</div>
</div>
Related
This question already has answers here:
Text in Border CSS HTML
(10 answers)
Closed 3 years ago.
im trying to turn a design into code with html and css, but im stumped at a part in the hero section. What's the best way to position this logo with the border that stops around it.
attached is an image of the design i am trying to re-create
you can use before and after classes as
::before and ::after then add border and position it on the top of the corner left and right.
*{
margin: 0; padding: 0; box-sizing: border-box;
}
body{
font-family: Arial , Helvetica;
}
.banner-container{
min-height: 600px; height: 100vh; background-image: linear-gradient(to bottom, rgba(60, 53, 39, 0.6), rgba(60, 53, 39, 0.7)), url("https://images.pexels.com/photos/2015972/pexels-photo-2015972.jpeg?cs=srgb&dl=affection-baby-child-2015972.jpg&fm=jpg"); background-position: center; background-size: cover; background-repeat: no-repeat;
}
.banner-wrap{
margin: 0 auto; max-width: 960px; height: 100%; display: flex; align-items: center; justify-content: center;
}
.banner-box{
border-bottom: solid #A58758 4px; border-left: solid #A58758 4px; border-right: solid #A58758 4px; width: 500px; display: flex; flex-direction: column; align-items: center; position: relative; padding: 50px; margin-top: 100px;
}
.banner-box::before{
content: "";
width: 127px;
border: solid #A58758 2px;
position: absolute;
top: -4px;
left: -4px;
}
.banner-box::after{
content: "";
width: 127px;
border: solid #A58758 2px;
position: absolute;
top: -4px;
right: -4px;
}
.banner-box img{
position: absolute; top: -135px; padding: 5px;
}
.banner-box h2{
color: #fff; font-size: 2.5rem;
}
.banner-box h1{
color: #fff; margin: 5px 0; text-transform: uppercase; font-weight: 400; font-size: 3.8rem; letter-spacing: .4rem;
}
.banner-box h3{
color: #A58758; text-transform: uppercase; font-size: 2.3rem; font-weight: 400; letter-spacing: .6rem;
}
a{
background: #A58758; color: #fff; text-decoration: none; text-transform: uppercase; padding: 15px 25px; position: absolute; bottom: -25px; letter-spacing: .1rem;
}
<div class="banner-container">
<div class="banner-wrap">
<div class="banner-box">
<img src="https://www.thorndalemanors.com/wp-content/uploads/2019/01/thorndale-footer.svg">
<h2>Refined Luxury</h2>
<h1>Singles</h1>
<h3>In Brampton</h3>
Learn More
</div>
</div>
</div>
check its working properly
This is what I would do:
Wrapper element (.box-border) with two children: .box-border__top & .box-border__img
Put a border on .box-border but no top border
For the top border, use .box-border__top consisting of three elements:
.box-border__top:before: a line
.box-border__img: the logo, aligned in the center
.box-border__top:after: a line
To add spacing around the image, use .box-border__content with padding: 5em
body {
background: url(https://www.goodfreephotos.com/albums/vector-images/farm-landscape-illustration-vector-graphics.png);
background-size: cover;
}
.box-border { /* All side borders by the top */
border: .5em solid brown;
border-top: 0;
text-align: center;
}
.box-border__top { /* Align the image & borders */
display: flex;
}
.box-border__top:before,
.box-border__top:after {
content: '';
display: block;
width: 100%;
border-top: .5em solid brown; /* Sections of the top image */
}
.box-border__img { /* Center Image */
transform: translateY(-50%);
margin: 0 0 -99%;
}
/* Add some padding on the bottom */
.box-border__content { padding: 5em; }
<div class="box-border">
<div class="box-border__top">
<img class="box-border__img" src="https://upload.wikimedia.org/wikipedia/commons/6/66/Android_robot.png" width="100" height="90" />
</div>
<div class="box-border__content">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Robogarden_img.png/800px-Robogarden_img.png" width="300" />
</div>
</div>
Currently I'm working on a website for a community and its getting a bit difficult, I have a nice pink>orange gradient with a image below it with a opacity of 0.2, to show both. That looks like this.
As you can see, the logo also has the opacity. I already found something about the rgba-color, but that did'nt work.
How can I solve this problem? I want the image with the border to have a full opacity.
body {
background-color: #f2f2f2;
color: #404040;
}
div.navbar {
height: 600px;
background: rgba(255, 255, 255, 0.7);
background-image: linear-gradient(25deg, #ec008c, #fc6767);
margin-top: -10px;
margin-left: -5px;
position: relative;
width: 105%;
}
img.logo {
position: absolute;
margin-top: 4%;
margin-left: 25%;
height: 40%;
padding: 25px;
border: 25px solid #f2f2f2;
border-radius: 50%;
}
div.image {
position: relative;
height: 100%;
opacity: 0.2;
background-image: url("img/slide1.jpg");
background-repeat: no-repeat;
background-size: cover;
}
div.nav {
position: absolute;
bottom: 0;
margin-left: 600px;
margin-bottom: 50px;
}
a.nav-item {
color: #f2f2f2;
font-weight: bold;
font-size: 25pt;
margin-right: 50px;
text-decoration: underline;
}
a.nav-item:hover,
a.nav-item .active {
text-decoration: overline underline;
}
<div class="navbar">
<img class="logo" src="img/logo.png">
<div class="image">
</div>
<div class="nav">
<a class="nav-item">Home</a>
<a class="nav-item">Twee</a>
</div>
</div>
Use the background property for both image and gradient. then take your gradient from the rgba equivalents of your hex values (Chrome dev tools color picker is good for this).
body {
margin: 0;
}
div.navbar {
height: 100vh;
/*
IMPORTANT BITS:
- ADDED image and gradient to navbar background and
- REMOVED opacity
THE REST:
The rest was just to make the demo look better/simpler
*/
background:
linear-gradient(25deg, rgba(236, 0, 140, 0.7), rgba(252, 103, 103, 0.7)),
url(http://placeimg.com/1000/600/arch) no-repeat center;
background-size: cover;
position: relative;
}
.logo-wrapper {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 25%;
height: 0;
padding-top: 25%;
border:25px solid #f2f2f2;
border-radius: 50%;
overflow: hidden;
}
.logo {
width: 90%;
border-radius: 50%;
position: absolute;
top: 5%;
left: 5%;
}
<html>
<head>
<link rel="stylesheet" href="css.css">
</head>
<body>
<div class="navbar">
<div class="logo-wrapper">
<img class="logo" src="http://placeimg.com/200/200/tech/grayscale">
</div>
</div>
</body>
</html>
Child can't override opacity of parent due to how opacity is managed by the browsers.
Simplest way to achieve this is to place the visual child after the parent and then use a negative margin-top to draw the child on top of the parent. You don't need absolute positioning.
.frame{
background-color: #AAAAAA;
opacity: 0.2;
border-radius: 13px;
padding: 21px;
color: #000000;
height: 73px;
}
.frametxt{
margin-top: -73px;
color: #000000 !important;
opacity: 1.0;
}
I have different div's which looks like this:
<div class="marker marker-availability" style="left: 975.516px; top: 346.265px;">
<span class="marker-label">Tenten comfort</span>
<div style="background-color:#7ba1bc" class="cluster-background">
<span class="marker-id">81</span>
</div>
</div>
<div class="marker marker-availability">
<span class="marker-label">Standaard kampeerplaatsen</span>
<div style="background-color:#d99200" class="cluster-background">
<span class="marker-id">81</span>
</div>
</div>
But now I have an issue because I set an :after with an image to the bottom of the image which looks like this:
Now you see the issue very clear, I tried to set the height to auto and set an min-height but this will not solve the problem.
I have recreated a jsfiddle: jsfiddle
Here is my less code:
&.marker-availability {
display: block;
width: 120px;
height: 23px;
color: #fff;
background-color: #6f6926;
border: 2px solid #fff;
border-radius: 2px;
margin-left: -60px;
margin-top: -26px;
.marker-label {
margin-top: 1px;
margin-left: 1px;
font-size: 12px;
font-weight: 500;
color: #fff;
}
.cluster-background {
.square(25px);
background-color: black;
color: #fff;
margin-top: -30px;
margin-left: -12px;
border-radius: 50%;
&:after {
.retina-image('/img/map/clustermarker-point.png', '/img/map/clustermarker-pointx2.png', 184px, 55px);
.pos-b-l(-26px, 50%);
.translate(-50%, -50%);
content: "";
display: block;
width: 120px;
height: 20px;
background-repeat: no-repeat;
}
}
.marker-id {
padding-top: 1px;
padding-left: 1px;
font-size: 15px;
}
}
Thereby, my question is it possible to make it look like this:
Or is it not possible because of the position of the :after image
The problem was primarily your negative margins which should be avoided if possible.
I've updated your example, you just need to adjust the paddings:
https://jsfiddle.net/txsv0ha5/
removed:
margin-top: -30px;
margin-left: -12px;
Also your bottom background shouldn't be an :after Element of your colored circles but rather of the whole marker itself.
You have some trouble with your css.
The main problem is the negative margin. If you do so, all the height of the parent is reduce. So, you need to add position:absolute.
Change the :after element to the parent so it will relative to the parent and not connected to the cluster-background.
.marker-availability {
display: block;
width: 120px;
min-height: 23px;
color: #fff;
background-color: #6f6926;
border: 2px solid #fff;
border-radius: 2px;
margin-top: 26px;
position:absolute;
}
.marker-availability .marker-label {
margin-top: 1px;
margin-left: 1px;
font-size: 12px;
font-weight: 500;
color: #fff;
}
.marker-availability .cluster-background {
width: 25px;
height: 25px;
background-color: black;
color: #fff;
margin-top: -50px;
margin-left: -12px;
border-radius: 50%;
position:absolute;
}
.marker-availability:after {
background: url('http://i65.tinypic.com/bhytdd.png');
position: absolute;
bottom: -26px;
left: 50%;
transform: translate(-50%, -50%);
content: "";
display: block;
width: 120px;
height: 20px;
background-repeat: no-repeat;
}
.marker-availability .marker-id {
padding-top: 1px;
padding-left: 1px;
font-size: 15px;
}
<body style="background-color: black">
<div class="marker marker-availability" style="left: 975.516px; top: 346.265px;"><span class="marker-label">Tenten comfort</span><div style="background-color:#7ba1bc" class="cluster-background"><span class="marker-id">81</span></div></div>
<div class="marker marker-availability"><span class="marker-label">Standaard kampeerplaatsen</span><div style="background-color:#d99200" class="cluster-background"><span class="marker-id">81</span></div></div>
</body>
I have a some text on image, but the problem is i am using opacity so that text gets highlighted but it makes images look very dull.
Here is Updated Fiddle Link
Html
<div class="subcontainer">
<img src="http://i58.tinypic.com/11kbnlf.png" alt="">
<h3 class="header3">Motivate Yourself</h3>
</div>
CSS
.subcontainer {
width: 100%;
height: 100%;
float: left;
position: relative;
border: 3px solid white;
}
.imgcolumn {
background-repeat: no-repeat;
float: left;
width: 60%;
height: 80%;
margin-left: 130px;
margin-top: 45px;
position: absolute;
opacity: 0.4;
filter: alpha(opacity=40);
}
.header3 {
z-index: 100;
position: absolute;
float:right;
color: black;
font-size: 25px;
margin-top: 175px;
text-align: center;
margin-left: 170px;
}
Is there any other way i can highlight text by keeping image as it is.
Note : I am trying to achieve something like this PAGE and i don't see image being blurred or having opacity.
use this fiddle
eg:
.header3 {
z-index: 100;
position: absolute;
float:right;
color: black;
font-size: 25px;
text-align: center;
position:absolute;
width:80%;
height:45%;
background-color:rgba(0,0,0,0.4);
top:20px;
left:24px;
line-height:150px;
}
You could also set the background-image of the parent container then lay another element over top of it with a semi-transparent background color as I have done here. Then, the highlight can be controlled via the opacity of the BACKGROUND of the overlay layer without affecting the text opacity.
http://jsfiddle.net/xDaevax/8Mzh9/
.subcontainer {
border: 3px solid white;
margin: 0px auto;
background: url("http://i61.tinypic.com/2ur6rk1.png") no-repeat center top;
height: 225px;
}
.imgcolumn {
width: 60%;
display: table;
height: 100%;
margin: 0px auto;
border: solid 1px #000000;
background-color: rgba(255, 255, 255, .6);
}
.header3 {
color: black;
font-size: 25px;
text-align: center;
position: relative;
top: -120px;
}
HTML
<div class="subcontainer">
<h3 class="header3">Motivate Yourself</h3>
</div>
The page you gave as an example uses contrasting colors for text and image. For example, that page uses dark images and the text on them is pure white.
If you want the text to stand out, use contrasting colors, or else use a contrasting drop shadow/outer glow (made with image editing software like PhotoShop), or add a semi-transparent background like this: http://jsfiddle.net/P22Cg/
.header3 {
z-index: 100;
position: absolute;
float:right;
color: black;
font-size: 25px;
margin-top: 175px;
text-align: center;
margin-left: 170px;
background-color: rgba(255, 255, 255, 0.5); /* I added this... */
padding: 5px; /* ... and this */
}
Hello not sure why but having some problem with a navigation. It seems to be overflowing and if I fix it in one browser it fails in the other. So I am not sure what is wrong with it. Recently the CSS broke and the entire menu is beyond messed up.
any ways heres is the site http://www.otaku-plus.com/triton
EDITED: updated code bit: http://jsfiddle.net/yukimura/hqyY2/embedded/result/
here is the css bit for the menu
#dropfish {
background-attachment: scroll;
background-clip: border-box;
background: #111111 url("images/top-bar-bg.png");
background-origin: padding-box;
background-position: 0% 0%;
background-repeat: repeat-x;
background-size: auto;
color: #000000;
left: 0px;
padding-left: 2px;
padding-right: 2px;
padding-top: 2px;
top: 0px;
width: 100%;
height: 44px;
position: fixed;
z-index: 9999;
box-shadow:0px 1px 2px;
}
#dropfish_menu {
width: 90%;
height: 44px;
margin: 0 auto;
}
#dropfish_menu ul {
width: 90%;
height: 44px;
}
#dropfish_menu ul li {
float: left;
padding: 14px 0px;
margin-top: -1px;
}
#dropfish_menu a {
color: #ffffff;
text-shadow:0 -1px 0 #000000;
padding: 14px 16px;
font-size: 14px;
}
#dropfish_menu a:hover {
margin-top: 0px;
padding: 14px 16px;
/* background-color:#cdcdcd; */
background-repeat: repeat;
background-color: #313131;
background-image: url("images/top-bar-bg.png");
background-position: 50% 75%;
cursor: pointer;
}
.active {
background-color: #313131;
background-image: url("images/top-bar-bg.png");
background-position: 50% 75%;
}
html bit for the menu
<div id="dropfish">
<div id="dropfish_menu">
<ul>
<div style="float:left;margin-left:-128px;">
<li><img src="http://opcdn.otaku-plus.com/themes/plus/images/logo.png" height="34px" style="margin-top: -8px;margin-right: 8px; cursor: pointer;" id="phx_return_logo"/></li>
<li>Web</li>
<li>Anime</li>
<li>Manga</li>
<li>News</li>
<li>Events</li>
<li>More</li>
</div>
<div style="float:right;margin-right:-128px;">
<li>Register</li><li>Sign in</li><li>Preferences</li>
</div>
</ul>
</div>
</div>
can some one tell me what is wrong with my CSS? or HTML
I made a possible solution to your problem. See this
#mainNav is floating left and #login is floating right.
I adjusted your mark up.