How to darken the lower part of the background image? - html

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).

Related

Two tone style background

I just need to style two-tone color background like this.
I tried and successfully did using linear gradient
background: linear-gradient(172deg, #ECB034 50%, #BE883C 50%);
But it has a problem when resizing web page. It just not well aligned to its corners. Showing weirdly. Like this
is there any way to did this?
.cta{
padding: 60px 0;
background: linear-gradient(172deg, #ECB034 50%, #BE883C 50%);
text-align:center;
}
.cta h3{
font-size: 58px;
margin-bottom: 30px;
font-weight: 700;
}
.cta a{
padding: 16px 49px;
border: 2px solid #000;
color: inherit;
font-size: 20px;
text-transform: uppercase;
display: inline-block;
font-weight: 500;
}
<div class="cta text-center">
<div class="container">
<h3>Let’s talk about your project.</h3>
Get Started >
</div>
</div>
This is a very simple fix with an SVG (as I mentioned in the comments) you simply need to add preserveAspectRatio="none" to the SVG tag and run it through a URL encoder. This one will even generate the CSS for you which is quite nice.
.cta{
padding: 60px 0;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='100%25' width='100%25' preserveAspectRatio='none' viewBox='0 0 10 10'%3E%3Crect width='10' height='10' fill='%23ECB034' /%3E%3Cpath d='m0 10 h10 v-10' fill='%23BE883C' /%3E%3C/svg%3E");
text-align:center;
}
.cta h3{
font-size: 58px;
margin-bottom: 30px;
font-weight: 700;
}
.cta a{
padding: 16px 49px;
border: 2px solid #000;
color: inherit;
font-size: 20px;
text-transform: uppercase;
display: inline-block;
font-weight: 500;
}
<div class="cta text-center">
<div class="container">
<h3>Let’s talk about your project.</h3>
Get Started >
</div>
</div>
You don't need anything complex. Simply change the angle with to bottom right
.cta{
padding: 60px 0;
background: linear-gradient(to bottom right, #ECB034 50%, #BE883C 50%);
text-align:center;
}
.cta h3{
font-size: 58px;
margin-bottom: 30px;
font-weight: 700;
}
.cta a{
padding: 16px 49px;
border: 2px solid #000;
color: inherit;
font-size: 20px;
text-transform: uppercase;
display: inline-block;
font-weight: 500;
}
<div class="cta text-center">
<div class="container">
<h3>Let’s talk about your project.</h3>
Get Started >
</div>
</div>
You can use pseudo and clip-path combination.
.box{
position:relative;
background-color: #ecae20;
text-align:center;
margin: 30px;
padding: 30px;
z-index:1;
}
.box .content{
position:relative;
z-index:3;
}
.box:before {
content: "";
position:absolute;
left:0;
bottom:0;
width: 100%;
height: 100%;
background-color: #BE883C;
clip-path: polygon(0 99%, 100% 0, 100% 99%, 0 100%);
opacity: 0.7;
z-index:2;
}
<div class="box">
<div class="content">
<p> Let's talk about your project </p>
<button> GET STARTED > </button>
</div>
</div>
As the angle needed changes with the aspect ratio it is not possible to do this with linear-gradient without some recalculation on every resize. (This is incorrect, see better suggestion from #temaniAfif using to bottom left etc.)
However, it is possible to create a triangle with its hypoteneuse being a diagonal by using clip-path and a polygon.
There is no need to inline an SVG if you put the two colors as backgrounds to the before and after pseudo elements, the after also having a clip-path.
.cta {
padding: 60px 0;
text-align: center;
position: relative;
}
.cta::before,
.cta::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.cta::before {
background-color: #ECB034;
}
.cta::after {
background-color: #BE883C;
clip-path: polygon(0 100%, 100% 0, 100% 100%);
}
.cta h3 {
font-size: 58px;
margin-bottom: 30px;
font-weight: 700;
}
.cta a {
padding: 16px 49px;
border: 2px solid #000;
color: inherit;
font-size: 20px;
text-transform: uppercase;
display: inline-block;
font-weight: 500;
}
<div class="cta text-center">
<div class="container">
<h3>Let’s talk about your project.</h3>
Get Started >
</div>
</div>
You can use pseudo element for the same.
#import "https://cdn.jsdelivr.net/gh/KunalTanwar/normalize/css/normalize.inter.min.css";
body {
height: 100%;
display: grid;
place-items: center;
}
.container {
--container-width: 400px;
--container-height: 200px;
width: 100%;
background-color: #ecb034;
height: var(--container-height);
max-width: var(--container-width);
}
.container::after {
content: "";
position: absolute;
width: 0;
height: 0;
user-select: none;
pointer-events: none;
inset: auto 0 0 auto;
border-bottom: var(--container-height) solid #be883c;
border-left: var(--container-width) solid transparent;
}
<div class="container"></div>
Make sure to keep border-left-width and width of the container same. And same for height.

How to eliminate animation flicker on button using css?

I created buttons that have a hover effect. The button fills from bottom to top with a background color white, and the text changes color. However, there is this weird line that appears at the bottom when the animation takes place. Any help would be greatly appreciated.
.project-button div {
position: relative;
display: inline-block;
padding: 1rem;
margin: 0 1rem 1rem 1rem;
font-size: 1rem;
font-weight: 700;
border: 1px solid white;
border-radius: 15px;
background-repeat: no-repeat;
transition: background-size .5s, color .5s;
}
.to-top {
background-position: 50% 100%;
background-size: 100% 0%;
}
.project-button a {
color: white;
}
.project-button div:hover {
background-size: 100% 100%;
background-image: linear-gradient(white, white);
}
.color-blue:hover {
color: #51d0de;
}
/* Misc */
html {
background: black;
margin: 1em;
}
<div class="project-button">
<div class="to-top color-blue">Visit Site</div>
</div>
Try the following:
I think the problem has to do with how Chrome computes the animation. At times (depending on the frame) the white background is just a bit too small to fill the button revealing the black background (hence the flicker).
.project-button div {
position: relative;
display: inline-block;
padding: 1rem;
margin: 0 1rem 1rem 1rem;
font-size: 1rem;
font-weight: 700;
border: 1px solid white;
border-radius: 15px;
background-image: linear-gradient(white, white);
background-repeat: no-repeat;
background-position: 0 -100%;
background-size: 100% 200%;
transition: background-position .5s, color .5s;
}
.project-button a {
color: white;
}
.project-button div:hover {
background-position: 0% 0%;
}
.color-blue:hover {
color: #51d0de;
}
/* Misc */
html {
background: black;
margin: 1em;
}
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<div class="project-button">
<div class="color-blue">Visit Site</div>
</div>
</body>
</html>
Inspired by Transition background-color via slide up animation

How to make the text decorationline line shorter in width

Hi guys I'm trying to figure out how to make the text-decoration-line shorter so it dosen't go all the way, i want it to look like this :
#about h1 {
font-weight: 600;
font-size: 17px;
color: #555;
text-align: center;
text-decoration-line: underline;
text-decoration-style: wavy;
}
<div id="about">
<div class="container">
<h1> GET TO KNOW US </h1>
</div>
</div>
Using bootstrap 3
Thanks
I would recreate it using gradient then put it inside a pseudo element then you can easily adjust size and position:
h1 {
font-weight: 600;
font-size: 17px;
color: #555;
text-align: center;
position: relative;
}
h1:before {
content: "";
position: absolute;
height: 12px;
top: 100%;
right:calc(50% - 40px);
width:80px;
background: radial-gradient(circle at 50% 100%, transparent 19%, gray 21%, gray 35%, transparent 35%, transparent), radial-gradient(circle at 50% 0%, transparent 19%, gray 21%, gray 34%, transparent 36%, transparent)-116px 0;
background-size: 16px 16px;
background-position: -9px 8px, 15px 3px;
}
<h1> GET TO KNOW US </h1>
Add a span and a pseudo class to it to get the red underline. You can change the width by adding more letters to the content:...
#about h1 {
font-weight: 600;
font-size: 17px;
color: #555;
text-align: center;
position: relative;
z-index: 2;
padding-bottom: 20px;
background-color:#fff;
}
.underline::before{
content: " aasd";
font-weight: 600;
font-size: 17px;
color: red;
text-align: center;
text-decoration-line: underline;
text-decoration-style: wavy;
display: block;
position: relative;
z-index: 1;
margin: auto;
margin-top: -29px;
}
<div id="about">
<div class="container">
<h1> GET TO KNOW US </h1><span class="underline"></span>
</div>
</div>

How to hide text in menu on hover and put image with underline instead?

I want to make menu on top, and on hover mouse to hide text and display icon. And to add underline under icon.In my code i successfully change text to image but how to add underline under image and make underline 3px wight and 60px length?
There is my code- HTML:
<div class="menu topMenu">
<ul class="topMenuOptions">
<li><span>111</span></li>
<li><span>222</span></li>
<li><span>333</span></li>
</ul>
CSS:
.topMenu {
text-transform: uppercase;
background-image: url('images/1.png');
position: absolute;
height: 88px;
width: 400px;
background: lightcoral;
margin-left: 332px;
padding-top: 30px;
}
.topMenuOptions {
padding: 0;
margin: 0;
margin-left: 155px;
list-style-type: none;
}
.topMenuOptions li {
cursor: pointer;
padding: 10px;
color: white;
font-size: 14px;
display: inline;
}
.topMenuOptions li:hover:nth-child(1) {
background: url('images/2.png') center center no-repeat;
background-position: 20px 0;
background-size: contain;
color:transparent;
}
.topMenuOptions li:hover:nth-child(2) {
background: url('images/3.png') center center no-repeat;
background-size: contain;
background-position: 20px 0;
color: transparent;
}
.topMenuOptions li:hover:nth-child(3) {
background: url('images/4.png') center center no-repeat;
background-size: contain;
background-position: 20px 0;
color: transparent;
}
Use border-bottom: 3px solid white;, for example:
.topMenuOptions li:hover:nth-child(1) {
background: url('images/2.png') center center no-repeat;
background-position: 20px 0;
background-size: contain;
color:transparent;
border-bottom: 3px solid #fff;
}
As per your requirement, I made a fiddle which you can check.
for the underline, you can keep border-bottom of 3px with border-color initially as transparent. this transparent color is required by default to avoid the jerking of the text when a border is added on hover.
I have modified your code a bit just for your understanding.
.topMenu {
text-transform: uppercase;
background-image: url('images/1.png');
position: absolute;
height: 88px;
width: 400px;
background: lightcoral;
/* margin-left: 332px; */
padding-top: 30px;
}
.topMenuOptions {
padding: 0;
margin: 0;
margin-left: 155px;
list-style-type: none;
}
.topMenuOptions li {
cursor: pointer;
padding: 10px;
color: white;
font-size: 14px;
display: inline;
border-bottom: 3px solid transparent;
}
.topMenuOptions li:hover:nth-child(1) {
background: url('http://php.quicoto.com/wp-content/uploads/2013/06/css3.jpg') center center no-repeat;
background-position: 0px 0;
background-size: contain;
color: transparent;
border-bottom: 3px solid #fff;
}
.topMenuOptions li:hover:nth-child(2) {
background: url('http://php.quicoto.com/wp-content/uploads/2013/06/css3.jpg') center center no-repeat;
background-size: contain;
background-position: 0px 0;
color: transparent;
border-bottom: 3px solid #fff;
}
.topMenuOptions li:hover:nth-child(3) {
background: url('http://php.quicoto.com/wp-content/uploads/2013/06/css3.jpg') center center no-repeat;
background-size: contain;
background-position: 0px 0;
color: transparent;
border-bottom: 3px solid #fff;
}
<div class="menu topMenu">
<ul class="topMenuOptions">
<li><span>111</span></li>
<li><span>222</span></li>
<li><span>333</span></li>
</ul>
JSFIDDLE
`<ul>
<li class="option">
<span id="text">111</span>
<span id="image" class="hide">IMAGE</span>
</li>
<li class="option">
<span id="text">222</span>
<span id="image" class="hide">IMAGE</span>
</li>
</ul>`
.option:hover .option > #image
{
display:block;
border-bottom:1px solid black;
}
.option:hover: .option > #text
{
display:none;
}
.hide
{
display:none;
}
you can do something like this, which is more efficient,
inside the image span you can add a image tag, which will also do the job.

Align text vertically center of h2 tag with a background

I have a h2 tag that has a background image as an icon. I want to align the text vertically within the h2 tag but it doesn't work. I have tried using the display: table-cell; but that hasn't worked either. The text may also crossover onto two lines.
HTML:
<ul class="FeatureRow">
<li><span><h2 class="SpeechBg">Need some help?</h2><p>Feel free to get in contact with us</p></span></li>
<li><span><h2 class="PinBg">Great locations!</h2></span></li>
<li><span><h2 class="ViewBg">View our apartments</h2></span></li>
</ul>
CSS:
a {
color: #2b6893;
text-decoration: none;
}
.FeatureRow{
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
.FeatureRow li{
float: left;
padding: 10px;
margin: 10px;
height: auto;
-webkit-box-shadow: 0px 4px 8px #f5f5f5;
-moz-box-shadow: 0px 4px 8px #f5f5f5;
box-shadow: 0px 4px 8px #f5f5f5;
background-color: #fdfdfd;
background-image: -moz-linear-gradient(top,#fbfbfb,#ffffff);
background-image: -webkit-gradient(linear,0 0,0 100%,from(#fbfbfb),to(#ffffff));
background-image: -webkit-linear-gradient(top,#fbfbfb,#ffffff);
background-image: -o-linear-gradient(top,#fbfbfb,#ffffff);
background-image: linear-gradient(to bottom,#fbfbfb,#ffffff);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbfbfb',endColorstr='#ffffffff',GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled= false);
}
.FeatureRow span{
display: block;
width: 260px;
}
.FeatureRow h2{
background-repeat: no-repeat;
padding-left: 65px;
font-size: 22px;
height: auto;
min-height: 60px;
color: #3F92ED;
}
.SpeechBg{
background-image: url(http://joshblease.co.uk/Apartments/images/icons/speech.png);
}
.PinBg{
background-image: url(http://joshblease.co.uk/Apartments/images/icons/pin.png);
}
.ViewBg{
background-image: url(http://joshblease.co.uk/Apartments/images/icons/view.png);
}
JSFiddle Example: http://jsfiddle.net/YPnTp/
In .SpeechBg, .PinBg, and .ViewBg, add line-height: ##px;, where ## is the height (in px) of the background images.
Change your
.FeatureRow h2 , add line-height
css as follows
.FeatureRow h2{
background-repeat: no-repeat;
padding-left: 65px;
font-size: 22px;
height: auto;
min-height: 60px;
color: #3F92ED;
line-height:2.5em;
}