CSS Three Tone Diagonal Background - html

I am trying to create a 3 color background with colors going diagonally.
I found a great example with colors i like here: Responsive Diagonal Two-Tone Backgrounds with CSS (Corner to Corner)
.btn {
background:#212531;
background: linear-gradient(to right bottom, #2f3441 50%, #212531 50%);
display:inline-block;
padding:0.75em 2.0em;
font-size:1.5em;
text-align:center;
margin:0.25em 0;
color:#ffffff;
font-weight:normal;
text-transform:uppercase;
font-family:sans-serif;
}
.btn:hover, .btn:focus {
background:#2d3d64;
background: linear-gradient(to right bottom, #415382 50%, #2d3d64 50%);
}
body { text-align:center; background:#e6e9f6; padding-top:1.0em; }
a { text-decoration:none; }
<a class="btn" href="#">Check Out My Background</a>
I want to modify this example to have a third color, going from the bottom left corner, diagonally up to the middle of the screen and then stopping there.
How can i achieve this?

You can try like below. Simply consider an extra gradient with a diagonal direction.
.box {
width:200px;
height:100px;
background:
linear-gradient(to bottom left ,transparent 50%,yellow 50.5%),
linear-gradient(to bottom right,red 50%,blue 50.5%);
}
<div class="box">
</div>

According to this example:
https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient
You can use something like that:
background: linear-gradient(217deg, rgba(255,0,0,.8), rgba(255,0,0,0) 70.71%),
linear-gradient(127deg, rgba(0,255,0,.8), rgba(0,255,0,0) 70.71%),
linear-gradient(336deg, rgba(0,0,255,.8), rgba(0,0,255,0) 70.71%);

Related

Showing part of the box [duplicate]

This question already has answers here:
How to color part of a box
(6 answers)
Closed 1 year ago.
I'm trying to show only part of the entire box.
<div class="box">30%</div>
.box{
background : linear-gradient(to right, rgba(250,0,0,0),rgba(250, 0, 0, 1));
}
The box looks like this, and I want to make only 30% of the background of the box colored and the rest transparent. I'm not trying to minimize the box to 30% width. I want the box's width to stay 100% but show only 30% of the gradient background.
If you wanna do it with the css background property, here you go:
background: background: linear-gradient(270deg, #F00 0%, rgba(255, 0, 0, 0.473958) 70.00%, rgba(255, 0, 0, 0) 70.01%, rgba(255, 0, 0, 0) 100%);
This is how it'll look line in a white background:
Notice the "70%" standing right there, it's where you can control where in the dimension you want a color to start (in this case rgba(255, 0, 0, 0) at 70% from the right border)
You can read more about it at MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient()#gradient_with_multi-position_color_stops
If I understand you correctly, you are wanting to have the left 70% transparent and have the gradient show only for the last 30%. If this is what you want you need to add 70% to your first colour stop as follows:
#box1{
background : linear-gradient(to right, rgba(250,0,0,0) 70%,rgba(250, 0, 0, 1));
}
#box2{
background : linear-gradient(to left, red, orange 70%, rgba(250,0,0,0) 30%);
}
#box3{
background : linear-gradient(to right, red 0%, orange 30%, white 30% );
}
.box {
margin-top: 15px;
}
<div class="box" id="box1">30%</div>
<div class="box" id="box2">30%</div>
<div class="box" id="box3">30%</div>
It looks like the OP was looking for something similar to a rainbow progress bar. There are many examples available including this one here: Progress bar different colors
Youn Can acheive it by:
css gradient background generator
with ::before and ::after
with clippath
span{
color:blue;
}
.box{
height:100px;
background: rgb(255,255,255);
background: linear-gradient(90deg, rgba(255,255,255,1) 30%, rgba(255,0,0,1) 30%);
}
.box2{
margin-top:30px;
position:relative;
height:100px;
}
.box2::before{
content:"";
position:absolute;
background-color:#000;
left:0;
top:0;
height:100%;
width:30%;
z-index:-1;
}
.box3{
background-color:#000;
height:100px;
margin-top:15px;
clip-path: inset(0 70% 0 0);
}
.box4{
margin-top:15px;
position:relative;
height:100px;
background: red; /* For browsers that do not support gradients */
background: -webkit-linear-gradient(left, orange , yellow, green, cyan, blue, violet); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(right, orange, yellow, green, cyan, blue, violet); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(right, orange, yellow, green, cyan, blue, violet); /* For Firefox 3.6 to 15 */
background: linear-gradient(to right, orange , yellow, green, cyan, blue, violet); /* Standard syntax (must be last) */
}
.box4::before{
content:"";
position:absolute;
top:0;
right:0;
width:70%;
height:100%;
background-color:#fff;
}
<div class="box">
<span>content<span>
</div>
<div class="box2">
<span>content<span>
</div>
<div class="box3">
<span>width clip path</span>
</div>
<div class="box4">
<span>As per your comment</span>
</div>

CSS - fading gradient border from-to

I want to make my whole div section with fading border. Here is my code:
.usermanagement {
-webkit-border-image: -webkit-gradient(
linear,
left top,
left bottom,
from(#fff),
to(#afd4ec),
color-stop(0.2, #afd4ec)
)
0 0 0 0 repeat repeat;
}
The effect is exactly what I want but only for top:
Then all goes to light blue and finishes like this:
Without this fading effect. I want to make the same effect as in the top for the bottom end of the section. How it is possible?
You can try like below. make sure to correctly set the different values.
.box {
height:50px; /* this need to be a multiple of 10 for the effect to work */
border-top: 10px solid;
border-bottom:10px solid;
background:#f2f2f2;
border-image:repeating-linear-gradient(#fff 0,red 10px) 10;
}
<div class="box"></div>
You can also do it with multiple background:
.box {
height:50px;
border-top:10px solid transparent;
border-bottom:10px solid transparent;
background:
linear-gradient(#fff ,red ) top,
linear-gradient(#fff ,red ) bottom, /* use (red, #fff) here for the opposite effect */
#f2f2f2;
background-size:100% 10px;
background-origin:border-box;
background-repeat:no-repeat;
}
<div class="box"></div>

Button color CSS transition/gradients

I'm looking to create a styled button for my app. The hope is to use css to generate a button which looks similar to:
The blue comes from the background so it's not relevant, its the shades of green I'm interested in. I'm not sure first if its possible to do it with CSS or how to do it if it is possible.
Can you start a gradient in the top left corner, move into a different colour from there and finish with a final colour at the bottom of the gradient?
If so are there any examples that you know of which I can refer too?
You can do this easily enough with a CSS-gradient using color stops. Here's a snippet example:
.gradientButton {
height: 50px;
width: 100px;
line-height:50px;
vertical-align:middle;
text-align:center;
font-family:arial;
font-size:26px;
font-weight:bold;
color:white;
text-shadow:2px 2px #336633;
box-shadow:2px 2px #336633;
border: 1px solid black;
border-radius:12px;
background: linear-gradient(to bottom right, LawnGreen 15%, green 85%, DarkGreen 90%);
}
.gradientButton:hover {
text-shadow:1px 1px #336633;
box-shadow:1px 1px #336633;
background: linear-gradient(to bottom right, LawnGreen 5%, green 80%, DarkGreen 85%);
}
<html>
<body>
<div class="gradientButton">log in</div>
</body>
</html>
Using things like gradients and shadows you can even provide hover effects like I've done here making it look like the button's depressed when you hover over it.

How to put a div between two different backgrounds

I want to put a div between two different backgrounds.
It looks something like below image:
As you can see, the div placed in between two background, white and blue.
How can I achieve this?
You can use position:absolute and a negative margin-top on the div you want in the middle
Check this
You can use below code by applying to that div. In this code you can use two different colors to background that you want.
background: linear-gradient(bottom, #FFFFFF 50%, #008ED3 50%);
background: -o-linear-gradient(bottom, #FFFFFF 50%, #008ED3 50%);
background: -moz-linear-gradient(bottom, #FFFFFF 50%, #008ED3 50%);
background: -webkit-linear-gradient(bottom, #FFFFFF 50%, #008ED3 50%);
background: -ms-linear-gradient(bottom, #FFFFFF 50%, #008ED3 50%);
In above code do not remove any single line, because each line is for browser compatibility, each line code is for different browsers.
You can position your white div so that it stacks on top of the divs with blue and white background.
https://jsfiddle.net/z6ohochn/
#blue {
background: blue;
width:100%;
height:60px;
}
#white {
width:80%;a
height:50px;
background:white;
z-index:2;
position:relative;
top:-80px;
left:10%;
border-radius:5px;
}
#gray {
background: gray;
width:100%;
height:60px;
}

Bootstrap 3 sign glyphicon with white circle background

Problem
Is there any way to make a Bootstrap 3.2 sign glyph to have a white background? It is being displayed on a coloured background. I've got an example on bootply but it has a white trim that is annoying.
CSS
.glyph-white-background {
background-color:#FFFFFF;
border-radius: 50%;
}
I had a play with the bootply and there may well be better ways of doing this but for now I sorted it by placing an inner span inside the glyphicon element and positioning it so that its border does not overlap the parents.
<div class="header">
<span class="glyphicon glyphicon-exclamation-sign glyph-background">
<span class="inner"></span>
</span>
</div>
The CSS positions the inner to provide the red background for the icon only.
.header {
background-color:#3AA3CB;
font-size: x-large;
}
.glyph-background {
position:relative;
border-radius:50%;
color:#fff;
z-index:2;
}
.inner {
position:absolute;
top:2px;
left:2px;
right:2px;
bottom:2px;
border-radius:50%;
background-color:red;
z-index:-1;
}
Bootply
I followed #Duroth 's advice and it works just fine.
HTML
<span class="not-available-icon"><i class="fa fa-exclamation"></i> </span>
CSS
.not-available-icon {
background-color: #9D5A5B;
display: inline-block;
height: 25px;
width: 25px;
color: white;
border-radius: 50%;
font-size: 16px;
padding-left: 10px;
}
JS Fiddle Here
You can use any color in :
.glyph-white-background {
background-color: red;//Say red
border-radius: 50%;
}
You should specify white color for class .glyph-red
.glyph-red {
color: white;
}
See the screenshot:
http://www.bootply.com/IRTWifeP2u
I consider this absolute overkill for what you're trying to accomplish, but at least it seems to work.
Using a gradient editor, I generated an image with a radial gradient that drops from 100% to 0% opacity at around 67% / 68%, making the image fully transparent just before it hits the edge of the icon.
The following CSS should work for just about every circle icon:
.glyph-white-background {
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPHJhZGlhbEdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY3g9IjUwJSIgY3k9IjUwJSIgcj0iNzUlIj4KICAgIDxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMSIvPgogICAgPHN0b3Agb2Zmc2V0PSI2NyUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMSIvPgogICAgPHN0b3Agb2Zmc2V0PSI2OCUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMCIvPgogICAgPHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjZmZmZmZmIiBzdG9wLW9wYWNpdHk9IjAiLz4KICA8L3JhZGlhbEdyYWRpZW50PgogIDxyZWN0IHg9Ii01MCIgeT0iLTUwIiB3aWR0aD0iMTAxIiBoZWlnaHQ9IjEwMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-radial-gradient(center, ellipse cover, rgba(255,255,255,1) 0%, rgba(255,255,255,1) 67%, rgba(255,255,255,0) 68%, rgba(255,255,255,0) 100%);
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,rgba(255,255,255,1)), color-stop(67%,rgba(255,255,255,1)), color-stop(68%,rgba(255,255,255,0)), color-stop(100%,rgba(255,255,255,0)));
background: -webkit-radial-gradient(center, ellipse cover, rgba(255,255,255,1) 0%,rgba(255,255,255,1) 67%,rgba(255,255,255,0) 68%,rgba(255,255,255,0) 100%);
background: -o-radial-gradient(center, ellipse cover, rgba(255,255,255,1) 0%,rgba(255,255,255,1) 67%,rgba(255,255,255,0) 68%,rgba(255,255,255,0) 100%);
background: -ms-radial-gradient(center, ellipse cover, rgba(255,255,255,1) 0%,rgba(255,255,255,1) 67%,rgba(255,255,255,0) 68%,rgba(255,255,255,0) 100%);
background: radial-gradient(ellipse at center, rgba(255,255,255,1) 0%,rgba(255,255,255,1) 67%,rgba(255,255,255,0) 68%,rgba(255,255,255,0) 100%);
}
Ofcourse, do mind your cross-browser compatibility.