This question already has answers here:
How do I combine a background-image and CSS3 gradient on the same element?
(20 answers)
Closed 4 months ago.
i have a problem with a div that has an image as a backround.
When I try to give it the linear gradient, the background disappears.
Thanks for the help and sorry for the triviality of the question, but I'm a beginner
.facebook{
background-image: url(/img/facebook.jpg) linear-gradient(from left, 1 , 0);
}
.menu2style{
border-top: solid 2px white;
border-bottom: solid 2px white;
height: 24.5%;
display: flex;
padding-left: 30px;
background-repeat: no-repeat;
background-size: cover;
font-family: 'Bungee Outline', cursive;
font-weight: 900;
font-size: 90%;
justify-content: flex-start;
color: white;
padding-right: 25%;
<div class="camera2">
<div class="menu2">
<div class="menu2style facebook">FACEBOOK</div>
For example:
.facebook {
background-image: url(https://images.unsplash.com/photo-1665507254439-fe45f1417c13?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwxNHx8fGVufDB8fHx8&auto=format&fit=crop&w=600&q=60), linear-gradient(to left, #000 50%, #fff 0%);
}
.menu2style {
border-top: solid 2px white;
border-bottom: solid 2px white;
height: 24.5%;
display: flex;
padding-left: 30px;
background-repeat: no-repeat;
background-size: cover;
font-family: 'Bungee Outline', cursive;
font-weight: 900;
font-size: 90%;
justify-content: flex-start;
color: white;
padding-right: 25%;
}
<div class="camera2">
<div class="menu2">
<div class="menu2style facebook">FACEBOOK</div>
</div>
</div>
Related
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>
How can I display this CSS icon using only a single DIV? I thought of a linear gradient as background, but I couldn't realize it myself until now.
Here you can see that it should work theoretically (of course with different colors).
How to color a single div with 3 different colors? (one third blue, one third white, one third red)
The first snippet shows how it should look, the second snippet is a very bad trial from me and somehow it does not turn out as it should even the hover effect fails... does anyone can get the whole thing right to work?
body {
font-size: 21px;
font-family: Tahoma, Geneva, sans-serif;
max-width: 550px;
margin: 0 auto;
background-color: gray;
}
.whitepaper {
cursor: pointer;
text-align: center;
background-color: white;
border: 2px solid black;
border-radius: 3px;
float: left;
font-family: Tahoma, Geneva, sans-serif;
font-size: 12px;
font-weight: bold;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
.blackframe {
text-align: center;
background-color: black;
cursor: pointer;
font-family: Tahoma, Geneva, sans-serif;
font-size: 12px;
font-weight: bold;
margin: 12px 0 12px 0;
color: white;
width: 30px;
}
.whitepaper:hover {
cursor: pointer;
text-align: center;
background-color: black;
border: 2px solid white;
border-radius: 3px;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
<div class="whitepaper">
<div class="blackframe">URL</div>
</div>
<div class="whitepaper">
<div class="blackframe">URL</div>
</div>
body {
font-size: 21px;
font-family: Tahoma, Geneva, sans-serif;
max-width: 550px;
margin: 0 auto;
background-color: gray;
}
.whitepaper {
align-items: center;
cursor: pointer;
text-align: center;
background: linear-gradient(to top, white 10px, black 1px, white);
border: 2px solid black;
border-radius: 3px;
color: white;
display: flex;
justify-content: center;
font-size: 12px;
font-weight: bold;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
.whitepaper:hover {
cursor: pointer;
text-align: center;
background-color: black;
border: 2px solid white;
border-radius: 3px;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
<div class="whitepaper">URL</div>
The way linear-gradient works is that the colors and values you list are stops, and CSS automatically fills in the space in between and blends it in a gradient. As mentioned in the linked question, the way to get sharp, instant transitions between colors is to create two stops at the same location: one with the old color, and one with the new. That way, there is no "in-between" space to fill with a gradient. You basically just list the starting and ending points for each color as stops, which is what I did here.
The reason your background colors weren't getting overridden on :hover is that you used background-color under the :hover selector, which doesn't override a linear-gradient. If you switch it to background, as I did, it works fine. I believe this sample works identically to the example you gave. You can adjust the px values in the linear-gradient if I didn't get them perfect.
body {
font-size: 21px;
font-family: Tahoma, Geneva, sans-serif;
max-width: 550px;
margin: 0 auto;
background-color: gray;
}
.whitepaper {
align-items: center;
cursor: pointer;
text-align: center;
background: linear-gradient(to top, white 12px, black 12px, black 28px, white 28px);
border: 2px solid black;
border-radius: 3px;
color: white;
display: flex;
justify-content: center;
font-size: 12px;
font-weight: bold;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
.whitepaper:hover {
cursor: pointer;
text-align: center;
background: black;
border: 2px solid white;
border-radius: 3px;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
<div class="whitepaper">URL</div>
Made some small changes. Changed the linear gradient into something opaque and added background sizing.
You can adjust the black part's size with background-size.
body {
font-size: 21px;
font-family: Tahoma, Geneva, sans-serif;
max-width: 550px;
margin: 0 auto;
background-color: gray;
}
.whitepaper {
align-items: center;
cursor: pointer;
text-align: center;
background-color: white;
background-image: linear-gradient(to right, rgba(0, 0, 0, 100) 50%, rgba(0, 0, 0, 100) 50%);
background-size: 100% 50%;
background-position-y: center;
background-repeat: no-repeat;
border: 2px solid black;
border-radius: 3px;
color: white;
display: flex;
justify-content: center;
font-size:12px;
font-weight:bold;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
.whitepaper:hover {
cursor: pointer;
text-align: center;
background-color: black;
border: 2px solid white;
border-radius: 3px;
float: left;
margin: 5px 5px 5px 0;
height: 40px;
width: 30px;
}
<div class="whitepaper">URL</div>
i trying to make background-position animation like this:
<div id="topAreaContainer">
<a href="http://www.google.co.il">
גכעגכע גע גכעגכע
</a>
</div>
body {
background: #000000;
direction: rtl;
}
#topAreaContainer {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 70px;
color: #ffffff;
width: 50%;
justify-content: center;
text-align: center;
}
#topAreaContainer a {
color: #ffffff;
text-decoration: none;
font-size: 1.5em;
background: transparent;
background: linear-gradient(to right, transparent 50%, #ffffff 50%);
background-size: 200% 100%;
background-position: left bottom;
transition: background-position 0.4s ease;
border: 3px solid #ffffff;
padding: 7px 25px;
margin: 0;
}
#topAreaContainer a:hover {
background-position: right bottom;
color: #78899c;
}
https://jsfiddle.net/Layfv2sj/
i tried to change the percent but nothing helped.
with english text its working fine.
what can i do?
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>
I would like to darken only lower part of the image and ofcourse with linear gradient, so that it goes from light on the top to dark at the bottom of the div.
If there is the other option to do that with div, where the text is there?
Do you need to do that in css or style inside html?
My html code where that background image is:
<div id="content-wide">
<div class="post">
<div class="imgwide" style="background-image: url(image.jpg); background-repeat: no-repeat; background-size: 100%; background-position: center;">
<div class="p-heading"><h1><?php the_title(); ?></h1>
<div class="p-content">
here is the text
</div>
</div>
</div>
</div>
</div>
my style.css contains these entries:
#content-wide {
position: relative;
width: 1180px;
float: left;
background: #F4F4F4;
margin-bottom: 19px;
}
.imgwide {
width: 1160px;
height: 450px;
margin: 10px 10px 10px 10px;
}
#content-wide .post, #content .page {
background-color: #F4F4F4;
}
#content-wide .p-heading {
position: absolute;
bottom: 0;
left:0;
width: 844px;
height: 180px;
}
#content-wide .p-heading h1 {
color: #F8F8F8;
font-size: 26px;
padding: 20px 20px 20px 30px;
}
#content-wide .p-heading h1 a {
color: #F8F8F8;
text-decoration: none;
text-transform: none;
}
#content-wide .p-heading h1 a:hover {
text-decoration: none;
color: #F8F8F8;
}
#content-wide .p-content {
padding: 0px 20px 20px 30px;
font-family: Frutiger, Lato;
font-size: 15px;
line-height: 16px;
text-align: none;
color: #EAEAEA;
}
You can use a CSS solution, check Transparency Gradient, it works like this :
background:linear-gradient(to bottom, rgba(0,0,0,0) 20%, rgba(0,0,0,1)), url('your_url');
This will darken the bottom of your background-image.
If you do not want to darken the image but the div on top of it then use :
background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 70%);
on your div (.p-heading).