Creating a gradient border for non-div element - html

i have bordered button (Non-div element, ). I need to get gradient color on the borders of my button. Now my button looks like this (In generally this is it):
.uibutton, uibutton:focus {
width: 120px;
height: 27px;
color: #007AFF;
outline: none;
border-radius: 3px;
border-width: 1px;
border-style: solid;
border-color: #007AFF;
background-color: transparent;
}
.uibutton:active {
width: 120px;
height: 27px;
color: #007AFF;
outline: none;
border-radius: 3px;
border-width: 2px;
border-style: solid;
background-color: transparent;
}
.uibutton:disabled {
width: 120px;
height: 27px;
color: #C7C7CC;
outline: none;
border-radius: 3px;
border-width: 1px;
border-color: #C7C7CC;
border-style: solid;
background-color: transparent;
}
<button class="uibutton">Hello World</button>
<button class="uibutton" disabled>Hello World</button>
I need gradient only in borders of button.
I'm so sorry, i'm idiot, just i confused in my code and how to write it.
Thanks for patience.

To add gradient background to button use code above or try CSS Gradient Generator.
.button {
width: 120px;
height: 27px;
outline: none;
border-radius: 3px;
box-sizing: border-box;
cursor: pointer;
}
.solid {
color: #fff;
border: none;
background: linear-gradient(150deg, #3acfd5 0%,#3a89d5 50%,#3a51d5 100%);
}
.thin {
border-left: none;
border-right: none;
border-top: 1px solid #1AD6FD;
border-bottom: 1px solid #1D62F0;
background-position: 0 0, 100% 0;
background-repeat: no-repeat;
background-size: 1px 100%;
background-color: transparent; /* removes button background */
background-image:
linear-gradient(to bottom, #1AD6FD 0%, #1D62F0 100%),
linear-gradient(to bottom, #1AD6FD 0%, #1D62F0 100%);
}
<button class="button solid">My button</button>
<button class="button thin">My button</button>

Related

Combining two different background-clips in hover state

Normal state:
Desired output in hover state:
I have a button that needs to clip the background on both the padding-box and the text in the hover state. I can achieve similiar behaviour by using border-image along with using background-clip: text, however there's no border-radius:
button {
background-color: #FFFFFF;
border: 2px solid black;
color: black;
padding: 15px 32px;
text-align: center;
border-radius: 5px;
}
button:hover {
border-image: url("https://i.imgur.com/drcgLxf.png");
border-image-slice: 30;
background: url("https://i.imgur.com/drcgLxf.png");
background-size: cover;
background-repeat: no-repeat;
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
<button>text here</button>
I found a way to use background-clip on both the text and the background itself by using a transparent border. I can't find a way to merge both of these together in a single hover state though, as there can only be specified a single background-clip on a single selector.
/* --- BACKGROUND CLIP TEXT ---*/
button.text {
border: 2px solid black;
border-radius: 5px;
background: white;
padding: 10px;
}
button.text:hover {
background: url("https://i.imgur.com/drcgLxf.png");
background-size: cover;
background-repeat: no-repeat;
z-index: 1;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
/* --- END ---*/
/* --- BACKGROUND CLIP PADDING-BOX ---*/
button.padding {
border: 2px solid black;
border-radius: 5px;
background: white;
background-clip: padding-box;
padding: 10px;
position: relative;
}
button.padding:hover {
border: 2px solid transparent;
}
button.padding::after {
position: absolute;
top: -2px;
bottom: -2px;
left: -2px;
right: -2px;
background: url('https://i.imgur.com/drcgLxf.png');
background-repeat: no-repeat;
background-size: cover;
content: '';
z-index: -1;
border-radius: 2px;
}
/* --- END --- */
<button class="text">clipped text</button>
<button class="padding">clipped padding-box</button>
Any JavaScript, jQuery or CSS-solution?
Use mask to combine both of them (related: Border Gradient with Border Radius)
button {
padding: 10px;
position: relative;
border: none;
background: var(--i,linear-gradient(#000 0 0)) center/cover repeat;
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
}
button::after {
content: '';
position: absolute;
inset: 0;
padding: 2px; /* the border thickness */
border-radius: 5px;
background: inherit;
background-clip: padding-box;
-webkit-mask:
linear-gradient(#000 0 0) content-box,
linear-gradient(#000 0 0);
-webkit-mask-composite: xor;
mask-composite: exclude;
}
button:hover {
--i: url('https://i.imgur.com/drcgLxf.png');
}
<button class="text">clipped text</button>

Having trouble aligining buttons with list bullets - HTML/CSS

I have an unordered list and the list items are the buttons like shown in the image.
Code Link
.btn {
overflow: visible;
margin: 0;
padding: 0;
border: 0;
background: transparent;
font: inherit;
line-height: normal;
cursor: pointer;
-moz-user-select: text;
display: block;
text-decoration: none;
text-transform: uppercase;
padding: 16px 36px 22px;
background-color: #fff;
color: #666;
border: 2px solid #666;
border-radius: 6px;
margin-bottom: 16px;
transition: all 0.5s ease;
border-radius: 15px;
box-shadow: 5px 7px #999;
}
.btn:-moz-focus-inner {
padding: 0;
border: 0;
}
.btn--stripe {
overflow: hidden;
position: relative;
}
.btn--stripe:after {
content: '';
display: block;
height: 7px;
width: 100%;
background-image: repeating-linear-gradient(45deg, #666, #666 1px, transparent 2px, transparent 5px);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
border-top: 1px solid #666;
position: absolute;
left: 0;
bottom: 0;
background-size: 7px 7px;
}
.btn--stripe:hover {
background-color: #666;
color: #fff;
border-color: #000;
box-shadow: 5px 10px 18px #888888;
/*box-shadow:20px 20px 50px grey; */
}
.btn--stripe:hover:after {
background-image: repeating-linear-gradient(45deg, #fff, #fff 1px, transparent 2px, transparent 5px);
border-top: 1px solid #000;
animation: stripe-slide 12s infinite linear forwards;
}
.child-btn {
font-size: 17px;
border-radius: 40px;
}
<ul id="list">
<li><button class="btn btn--stripe child-btn" type="submit" name="tt_btn" value="BMS">BMS Room</button></li>
<li><button class="btn btn--stripe child-btn" type="submit" name="tt_btn" value="LH310">LH-310</button></li>
</ul>
The buttons are not able to align with the bullets, can anyone help me where I am going wrong?
Edit: Problem solved. The problem was in Firefox where I had to remove display: block; from my CSS. In Chrome, it works fine.
Here is the working snippet for both Chrome & Firefox.
fiddle to validate.
You just have to remove display:block; from the .btn{...} class.
.btn {
overflow: visible;
margin: 0;
padding: 0;
border: 0;
background: transparent;
font: inherit;
line-height: normal;
cursor: pointer;
-moz-user-select: text;
text-decoration: none;
text-transform: uppercase;
padding: 16px 36px 22px;
background-color: #fff;
color: #666;
border: 2px solid #666;
border-radius: 6px;
margin-bottom: 16px;
transition: all 0.5s ease;
border-radius: 15px;
box-shadow: 5px 7px #999;
}
.btn:-moz-focus-inner {
padding: 0;
border: 0;
}
.btn--stripe {
overflow: hidden;
position: relative;
}
.btn--stripe:after {
content: '';
display: block;
height: 7px;
width: 100%;
background-image: repeating-linear-gradient(45deg, #666, #666 1px, transparent 2px, transparent 5px);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
border-top: 1px solid #666;
position: absolute;
left: 0;
bottom: 0;
background-size: 7px 7px;
}
.btn--stripe:hover {
background-color: #666;
color: #fff;
border-color: #000;
box-shadow: 5px 10px 18px #888888;
/*box-shadow:20px 20px 50px grey; */
}
.btn--stripe:hover:after {
background-image: repeating-linear-gradient(45deg, #fff, #fff 1px, transparent 2px, transparent 5px);
border-top: 1px solid #000;
animation: stripe-slide 12s infinite linear forwards;
}
.child-btn {
font-size: 17px;
border-radius: 40px;
}
<ul id="list">
<li><button class="btn btn--stripe child-btn" type="submit" name="tt_btn" value="BMS">BMS Room</button></li>
<li><button class="btn btn--stripe child-btn" type="submit" name="tt_btn" value="LH310">LH-310</button></li>
</ul>
#list {
align-items: left;
display: flex;
flex-direction: column;
}
.btn {
width: 20vw;
border-radius: 20vw;
height: 15vh;
margin-top: 2vh;
}
<ul id="list">
<li><button class="btn btn--stripe child-btn" type="submit" name="tt_btn" value="BMS">BMS Room</button></li>
<li><button class="btn btn--stripe child-btn" type="submit" name="tt_btn" value="LH310">LH-310</button></li>
</ul>

Input range with split colors using CSS

Is it possible to restyle a input range to have different colors on the right and left side of the tracker just by CSS? This is what i have gotten so far.
input[type=range] {
margin: 10px 0;
margin: 50px;
width: 500px;
background: transparent;
-webkit-appearance: none;
}
input[type=range]::-webkit-slider-runnable-track {
height: 10px;
background: white;
border-radius: 5px;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
border: none;
height: 25px;
width: 25px;
border-radius: 50%;
background: white;
border: 3px green solid;
margin-top: -7px;
}
input[type=range]:focus {
outline: none;
}
body {
background-color: green;
}
<input type="range" min="0" max="10" />
https://jsfiddle.net/Lautaro/k179gwur/1/
Yeah, you could use css gradient.
input[type=range]::-webkit-slider-runnable-track {
background: linear-gradient(to right, #000000 0%,#000000 50%,#ffffff 50%,#ffffff 100%,#ffffff 100%);
}
As far as I know it is not possible to do using only CSS.
Alternatively you can easily accomplish it with a tiny bit of javascript.
Use this: https://toughengineer.github.io/demo/slider-styler
for (let e of document.querySelectorAll('input[type="range"].slider-progress')) {
e.style.setProperty('--value', e.value);
e.style.setProperty('--min', e.min == '' ? '0' : e.min);
e.style.setProperty('--max', e.max == '' ? '100' : e.max);
e.addEventListener('input', () => e.style.setProperty('--value', e.value));
}
/*surrounding background color*/
body {
background: green;
}
/*generated with Input range slider CSS style generator (version 20201223)
https://toughengineer.github.io/demo/slider-styler*/
input[type=range].styled-slider {
height: 2.2em;
-webkit-appearance: none;
/*added this property to generated CSS to match the surrounding background color*/
background: transparent;
/*specify desired width*/
width: 500px;
}
/*progress support*/
input[type=range].styled-slider.slider-progress {
--range: calc(var(--max) - var(--min));
--ratio: calc((var(--value) - var(--min)) / var(--range));
--sx: calc(0.5 * 2em + var(--ratio) * (100% - 2em));
}
input[type=range].styled-slider:focus {
outline: none;
}
/*webkit*/
input[type=range].styled-slider::-webkit-slider-thumb {
width: 2em;
height: 2em;
border-radius: 1em;
background: #007cf8;
border: none;
box-shadow: 0 0 2px black;
margin-top: calc(max((1em - 1px - 1px) * 0.5,0px) - 2em * 0.5);
-webkit-appearance: none;
}
input[type=range].styled-slider::-webkit-slider-runnable-track {
height: 1em;
border-radius: 0.5em;
background: #efefef;
border: 1px solid #b2b2b2;
box-shadow: none;
}
input[type=range].styled-slider::-webkit-slider-thumb:hover {
background: #0061c3;
}
input[type=range].styled-slider:hover::-webkit-slider-runnable-track {
background: #e5e5e5;
border-color: #9a9a9a;
}
input[type=range].styled-slider::-webkit-slider-thumb:active {
background: #2f98f9;
}
input[type=range].styled-slider:active::-webkit-slider-runnable-track {
background: #f5f5f5;
border-color: #c1c1c1;
}
input[type=range].styled-slider.slider-progress::-webkit-slider-runnable-track {
background: linear-gradient(#007cf8,#007cf8) 0/var(--sx) 100% no-repeat, #efefef;
}
input[type=range].styled-slider.slider-progress:hover::-webkit-slider-runnable-track {
background: linear-gradient(#0061c3,#0061c3) 0/var(--sx) 100% no-repeat, #e5e5e5;
}
input[type=range].styled-slider.slider-progress:active::-webkit-slider-runnable-track {
background: linear-gradient(#2f98f9,#2f98f9) 0/var(--sx) 100% no-repeat, #f5f5f5;
}
/*mozilla*/
input[type=range].styled-slider::-moz-range-thumb {
width: 2em;
height: 2em;
border-radius: 1em;
background: #007cf8;
border: none;
box-shadow: 0 0 2px black;
}
input[type=range].styled-slider::-moz-range-track {
height: max(calc(1em - 1px - 1px),0px);
border-radius: 0.5em;
background: #efefef;
border: 1px solid #b2b2b2;
box-shadow: none;
}
input[type=range].styled-slider::-moz-range-thumb:hover {
background: #0061c3;
}
input[type=range].styled-slider:hover::-moz-range-track {
background: #e5e5e5;
border-color: #9a9a9a;
}
input[type=range].styled-slider::-moz-range-thumb:active {
background: #2f98f9;
}
input[type=range].styled-slider:active::-moz-range-track {
background: #f5f5f5;
border-color: #c1c1c1;
}
input[type=range].styled-slider.slider-progress::-moz-range-track {
background: linear-gradient(#007cf8,#007cf8) 0/var(--sx) 100% no-repeat, #efefef;
}
input[type=range].styled-slider.slider-progress:hover::-moz-range-track {
background: linear-gradient(#0061c3,#0061c3) 0/var(--sx) 100% no-repeat, #e5e5e5;
}
input[type=range].styled-slider.slider-progress:active::-moz-range-track {
background: linear-gradient(#2f98f9,#2f98f9) 0/var(--sx) 100% no-repeat, #f5f5f5;
}
/*ms*/
input[type=range].styled-slider::-ms-fill-upper {
background: transparent;
border-color: transparent;
}
input[type=range].styled-slider::-ms-fill-lower {
background: transparent;
border-color: transparent;
}
input[type=range].styled-slider::-ms-thumb {
width: 2em;
height: 2em;
border-radius: 1em;
background: #007cf8;
border: none;
box-shadow: 0 0 2px black;
margin-top: 0;
box-sizing: border-box;
}
input[type=range].styled-slider::-ms-track {
height: 1em;
border-radius: 0.5em;
background: #efefef;
border: 1px solid #b2b2b2;
box-shadow: none;
box-sizing: border-box;
}
input[type=range].styled-slider::-ms-thumb:hover {
background: #0061c3;
}
input[type=range].styled-slider:hover::-ms-track {
background: #e5e5e5;
border-color: #9a9a9a;
}
input[type=range].styled-slider::-ms-thumb:active {
background: #2f98f9;
}
input[type=range].styled-slider:active::-ms-track {
background: #f5f5f5;
border-color: #c1c1c1;
}
input[type=range].styled-slider.slider-progress::-ms-fill-lower {
height: max(calc(1em - 1px - 1px),0px);
border-radius: 0.5em 0 0 0.5em;
margin: -1px 0 -1px -1px;
background: #007cf8;
border: 1px solid #b2b2b2;
border-right-width: 0;
}
input[type=range].styled-slider.slider-progress:hover::-ms-fill-lower {
background: #0061c3;
border-color: #9a9a9a;
}
input[type=range].styled-slider.slider-progress:active::-ms-fill-lower {
background: #2f98f9;
border-color: #c1c1c1;
}
<input type="range" class="styled-slider slider-progress" />

Button Border Color Issues

I have created a button with the following HTML and CSS code.
.btnstyle2{
height: 28px;
text-align: center;
background-color: #F8F8F8;
border-radius: 3px;
border-color: #E8E8E8;
}
<button type="button" class="btnstyle2">Dismiss</button>
The issues I am having is getting rid of the right and bottom borders that are darker than the left and top borders. I need the entire border for the button to be the light gray that is stated in the CSS code as border-color: #E8E8E8. Any help would be great! Thanks!
The button is using the default styling. By setting the border to solid will override the default styles.
You can combine the border declaration of width, style and colour into one line like so:
.btnstyle2{
height: 28px;
text-align: center;
background-color: #F8F8F8;
border-radius: 3px;
border: 2px solid #E8E8E8;
}
<button type="button" class="btnstyle2">Dismiss</button>
You've got a outset style, that's default in buttons (inset in inputs for example).
If you need a solid border add this:
border-style: solid;
You can view it:
.btnstyle2{
height: 28px;
text-align: center;
background-color: #F8F8F8;
border-radius: 3px;
border-color: #E8E8E8;
border-style:solid;
}
<button type="button" class="btnstyle2">Dismiss</button>
Use this for the border.
border:1px solid #e8e8e8;
Just override the button default class unwanted properties:
button {
align-items: flex-start;
text-align: center;
cursor: default;
color: buttontext;
padding: 2px 6px 3px;
border: 2px outset buttonface; /* bad */
border-image-source: initial;
border-image-slice: initial;
border-image-width: initial;
border-image-outset: initial;
border-image-repeat: initial;
background-color: buttonface;
box-sizing: border-box;
}
Example:
.btnstyle2{
height: 44px;
width: 46px;
text-align: center;
border-radius: 3px;
border-color: #E8E8E8;
border: none; /* new here */
background: url('https://www.linkedin.com/scds/common/u/images/logos/linkedin/logo_in_nav_44x36.png') left center no-repeat;
}
Please try this one:
Html
<button type="button" class="button1">Demo button</button>
Css:
.button1{
height: 28px;
text-align: center;
background-color:#F3F3F3;
border-radius: 3px;
border-color: #E8E8E8;
border-style:solid;
}
DEMO
You can use border: attribute insted of border-color: which you used to style borders in CSS. Also you can edit border-color, border-style on a single line like I have shown below.
The CSS:
.btnstyle2{
height: 28px;
text-align: center;
background-color: #F8F8F8;
border:2px solid #E8E8E8;
border-style:solid;
}
HTML:
<button type="button" class="btnstyle2">Dismiss</button>

How to Style an hr Tag Using CSS and HTML?

How can I style an hr tag?
#footer hr
{
background-image: -moz-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
}
This doesn't work in firefox. I even tried background:, but that didn't work. Is there some other way to make it work?
Its working
you need to just use hr in div with your css id footer. As like below
<div id="footer">
<hr />
</div>
Try background: instead of background-image:
See here for a working example in Firefox:
http://playground.genelocklin.com/gradient-hr/
You need to specify the height of the <hr />
look this
Well, you could try making a div like so:
CSS:
div.hr{
background-image:url('yourimage.jpg');
height: 5px;
width: 400px; /*About the size of the content area that you are putting it in*/
margin-left: auto;
margin-right: auto;
}
HTML:
<div id="hr">
</div>
Have any questions?
EDIT:
With taking a look at Charlie's answers, you could try something like this:
<div id="footer">
<hr id="footer" />
</div>
#footer
{
height:10px;
background-color: black;
padding: 0px
}
.myhr {
border: 0;
height: 1px;
background: #333;
background-image: -webkit-linear-gradient(left, #ccc, #333, #ccc);
background-image: -moz-linear-gradient(left, #ccc, #333, #ccc);
background-image: -ms-linear-gradient(left, #ccc, #333, #ccc);
background-image: -o-linear-gradient(left, #ccc, #333, #ccc);
}
hrshadow {
height: 12px;
border: 0;
box-shadow: inset 0 12px 12px -12px rgba(0,0,0,0.5);
}
/****************************/
Newhr {
height: 30px;
border-style: solid;
border-color: black;
border-width: 1px 0 0 0;
border-radius: 20px;
}
Newhr:before {
display: block;
content: "";
height: 30px;
margin-top: -31px;
border-style: solid;
border-color: black;
border-width: 0 0 1px 0;
border-radius: 20px;
}
.hrstyle {
padding: 0;
border: none;
border-top: medium double #333;
color: #333;
text-align: center;
}
.hrstyle:after {
content: "ยง";
display: inline-block;
position: relative;
top: -0.7em;
font-size: 1.5em;
padding: 0 0.25em;
background: white;
}
/****dashed line *****/
.dash_hr {
border: 0;
border-bottom: 1px dashed #ccc;
background: #999;
}