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>
Related
My button looks like this (atachement) and my CSS Code for the Button looks like that and it is double colored. How can I change it that it is just light green:
.button {
font-size: 1rem;
font-weight: bold;
padding: 1em 2em;
cursor: pointer;
background: transparent;
color: white;
border-color: hsl(126, 100%, 30%);
border-radius: 1.5em/50%;
}
Image
You can set your border's "style" to solid, right now it is set to inset. Add border-style: solid to your CSS:
.button {
font-size: 1rem;
font-weight: bold;
padding: 1em 2em;
cursor: pointer;
background: transparent;
color: white;
border-color: hsl(126, 100%, 30%);
border-radius: 1.5em/50%;
border-style: solid;
}
If you want to revert the changes either remove border-style: solid; or use border-style: inset;
More on border-style
the border-style has to be defined which is defined as solid in the below code, if it is not defined it will have to use inset border-style as the border-style which is the default
.button {
font-size: 1rem;
font-weight: bold;
padding: 1em 2em;
cursor: pointer;
background: transparent;
color: white;
border: solid 1px hsl(126, 100%, 30%);
border-radius: 1.5em/50%;
}
Edge creates the perfect inset border, but the outset border is wrong.
Pictures here:https://imgur.com/a/pKavy1K
The only change in code between these two pictures is changing the border-style from outset to inset. Why are the colors not exactly the same but swapped?
.SmallButton {
color: grey;
font-family: "Segoe UI";
font-weight: bold;
background-color: white;
font-size: 15px;
border-radius: 30px;
border-style: inset;
-moz-border-radius: 30px;
-webkit-border-radius: 30px;
margin-top: 20px !important;
width: 230px !important;
height: 36px !important;
}
<input class="SmallButton" type="submit" value="Sign Up">
Browsers sometimes have slightly different approaches on how to display certain UI elements. It's best to style them manually by applying specific CSS properties.
You can change the border-style to solid and apply border-color for each side to get the preferred result.
.button {
background-color: #FFFFFF;
border-radius: 18px;
border-style: solid;
border-width: 2px;
color: #808080;
cursor: pointer;
font-size: 15px;
font-weight: bold;
height: 36px;
max-width: 230px;
width: 100%;
}
.button-outset {
border-color: #F0F0F0 #A0A0A0 #A0A0A0 #F0F0F0;
}
.button-inset {
border-color: #A0A0A0 #F0F0F0 #F0F0F0 #A0A0A0;
}
<input type="submit" class="button button-outset" value="Outset button">
<br><br>
<input type="submit" class="button button-inset" value="Inset button">
I really doubt what I am asking is possible but it's still worth a try.
I am trying to create a button that normally has background-color: transparent; color: white; and when you hover over it, those properties should swap. The problem is that if you just swap them then all you see is a white button. If you know the background colour of the containing element then you can get the colour from there but If the button is over an image or a canvas then this won't work.
This is how I've been doing it so far
html,
body {
height: 100%;
}
#container {
background-color: #38404D;
height: 100%;
}
.ghost-button {
background-color: transparent;
border: 1px solid #ffffff;
outline: none !important;
transition: all 0.8s;
margin: 10px 10px;
padding: 6px 7px;
cursor: pointer;
color: #ffffff;
}
.ghost-button:hover {
background-color: #ffffff;
color: #38404D;
}
.ghost-button:active {
box-shadow: inset 0 0 8px 0px #888888;
}
<div id="container">
<button class="ghost-button">Hover Here</button>
</div>
UPDATE
It seems that quite a few people were confused by the question. I am asking if there is a way to do the exact same thing I've done above but on top of an image or a canvas (instead of a solid colour). See example below
html,
body {
height: 100%;
}
#container {
background-image: url("http://www.freegreatpicture.com/files/147/17878-hd-color-background-wallpaper.jpg");
height: 100%;
}
.ghost-button {
background-color: transparent;
border: 1px solid #ffffff;
outline: none !important;
transition: all 0.8s;
margin: 10px 10px;
padding: 6px 7px;
cursor: pointer;
color: #ffffff;
}
.ghost-button:hover {
background-color: #ffffff;
color: #38404D;
}
.ghost-button:active {
box-shadow: inset 0 0 8px 0px #888888;
}
<div id="container">
<button class="ghost-button">Hover Here</button>
</div>
Yes, it IS possible in CSS with mix-blend-mode.
Answer's update in April 2021: Currently it have a very solid support (95% globally) although Safari doesn't have hue, saturation, color, and luminosity blend modes. Of course, IE isn't a considerable thing if you expect to use it (like many of other cool CSS features of the last years).
.ghost-button {
/* Important part */
mix-blend-mode: screen;
background: #000;
color: #fff;
/* Button cosmetics */
border: .125em solid #fff;
font: 2em/1 Cursive;
letter-spacing: 1px;
outline: none !important;
transition: all .8s;
padding: .5em 1em;
cursor: pointer;
}
.ghost-button:hover {
/* Important part */
background: #fff;
color: #000;
}
#container {
background: url('http://www.freegreatpicture.com/files/147/17878-hd-color-background-wallpaper.jpg') center/cover;
/* Also works with background-color or gradients: */
/* background: linear-gradient(to right, red, yellow); */
/* Container positioning */
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
html, body {
margin: 0;
}
<div id="container">
<button class="ghost-button">Hover Here</button>
</div>
As you can see, the secret here is using mix-blend-mode: screen along with the black color for the "erased" part, since black is mixed with the background when using this screen mode.
No, it isn't possible in CSS! You could try to set the color with JS to mimic this effect.
body {
height: 100%;
}
#container {
background-color: #38404D;
height: 100%;
}
.ghost-button {
background-color: transparent;
border: 1px solid #ffffff;
outline: none !important;
transition: all 0.8s;
margin: 10px 10px;
padding: 6px 7px;
cursor: pointer;
color: #ffffff;
}
.ghost-button:hover {
background-color: none;
color: red;
}
.ghost-button:active {
box-shadow: inset 0 0 8px 0px #888888;
}
<div id="container">
<button class="ghost-button">Hover Here</button>
</div>
hover color is set to red you can update it.
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>
I'm trying to create a input box that has only one border (i.e. border-left), but every time I put border-left to the selector, the top, right, bottom border show up (with that beveled and embossed look). Here's what I have right now.
HTML
<input type="text" id="fullname" class="detail" name="fullname" value="" />
CSS
.detail {
border-left: 1px #fff solid;
background: transparent;
width: 490px;
height: 30px;
padding-left: 10px;
}
Here's my JSFiddle: http://jsfiddle.net/XRFB3/
Set your default border first:
.detail {
border:0;
border-left: 1px #fff solid;
background: transparent;
width: 490px;
height: 30px;
padding-left: 10px;
}
JSFiddle
Try to reset borders first like border: none;. That is because browsers apply default user agent styles if the custom is not defined.
.detail {
border: none;
border-left: 1px #fff solid;
background: transparent;
width: 490px;
height: 30px;
padding-left: 10px;
}
Use the following
border: none;
border-left: 1px Solid #fff;
instead of
border-left: 1px #fff solid;