How to make a transparent HTML button? - html

I am using dreamweaver to create a website and I thought of just using Photoshop to create backgrounds. I decided to do so only because in case I'd choose to change the button name easily by just editing the codes, I could just refer to the code. If I would construct buttons using Photoshop, I wouldn't be able to edit the Texts in those buttons or in any element easily.
So my question is simple, How do I create a button that has a simple inline style making it transparent leaving the value of the button still visible.
.button {
background-color: Transparent;
background-repeat:no-repeat;
border: none;
cursor:pointer;
overflow: hidden;
}
It still leaves a border shade after your click it.

To get rid of the outline when clicking, add outline:none
JSFiddle example
button {
background-color: transparent;
background-repeat: no-repeat;
border: none;
cursor: pointer;
overflow: hidden;
outline: none;
}
button {
background-color: transparent;
background-repeat: no-repeat;
border: none;
cursor: pointer;
overflow: hidden;
outline: none;
}
<button>button</button>

The solution is pretty easy actually:
<button style="border:1px solid black; background-color: transparent;">Test</button>
This is doing an inline style. You're defining the border to be 1px, solid line, and black in color. The background color is then set to transparent.
UPDATE
Seems like your ACTUAL question is how do you prevent the border after clicking on it. That can be resolved with a CSS pseudo selector: :active.
button {
border: none;
background-color: transparent;
outline: none;
}
button:focus {
border: none;
}
JSFiddle Demo

Make a div and use your image ( png with transparent background ) as the background of the div, then you can apply any text within that div to hover over the button. Something like this:
<div class="button" onclick="yourbuttonclickfunction();" >
Your Button Label Here
</div>
CSS:
.button {
height:20px;
width:40px;
background: url("yourimage.png");
}

<div class="button_style">
This is your button value
</div>
.button_style{
background-color: Transparent;
border: none; /* Your can add different style/properties of button Here*/
cursor:pointer;
}

Setting its background image to none also works:
button {
background-image: none;
}

**add the icon top button like this **
#copy_btn{
align-items: center;
position: absolute;
width: 30px;
height: 30px;
background-color: Transparent;
background-repeat:no-repeat;
border: none;
cursor:pointer;
overflow: hidden;
outline:none;
}
.icon_copy{
position: absolute;
padding: 0px;
top:0;
left: 0;
width: 25px;
height: 35px;
}
<button id="copy_btn">
<img class="icon_copy" src="./assest/copy.svg" alt="Copy Text">
</button>

Related

scrolls bar hidden but one show

I am working on a website where scrolling has been completely disabled using this css style.
::-webkit-scrollbar {display: none;}
But now I need a specific scroll inside a div (horizontal scroll) to be visible. How could I show only one scroll while hiding all the others.
Thanks in advance
Use this
body::-webkit-scrollbar {
width: 6px;
border-radius: 4px;
background: transparent;
display: block;
}
body::-webkit-scrollbar-thumb {
width: 6px;
border-radius: 0px;
background: #000000;
}
try instead of hiding all the scrollbars hide same of them
div {
width: 150px;
height: 50px;
border: 1px solid #000;
overflow-x: scroll;
}
.ele-2::-webkit-scrollbar {display: none;}
<div class="ele-1">aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccdddddddddddddddddd</div>
<div class="ele-2">aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccdddddddddddddddddd</div>

Change Image Color in Button

I'm having trouble in changing the image color inside of a button.
Here's the image.
I want the black download button icon change to green icon if possible in CSS? or any other way to make it like that? Instead of re-creating it again
And for the code:
<button><em class="leftImage"></em>Button<em class='rightImage'></em></button>
button{
margin: 0px;
padding: 0px;
font-family:Lucida Sans MS, Tahoma;
font-size: 12px;
color: #000;
white-space:nowrap;
width:auto;
overflow:visible;
height:28px;
}
button em{
vertical-align:middle;
margin:0 2px;
display:inline-block;
width:16px;
height:16px;
background-image: url(icon_delete.png);
}
button em.leftImage{
background-position: -96px -112px;
}
button em.rightImage{
background-position: -64px -16px;
}
But the output is not changing the color. its still black.
https://jsfiddle.net/35kfu6z7/
You original code doesn't make much sense.
What you have here is an image with the 2 versions of your button. You can use a technique called CSS Sprites: https://css-tricks.com/css-sprites/
The idea here is to force the size of the button element to be the same size as the button on your image, then offset it using the background-position property to align it properly inside your button.
Here is an example using the picture you provided and 2 different clases (with 2 different offset) to show either the green or the black:
button{
display:inline-block;
width:84px;
height:26px;
background-image: url(http://i.stack.imgur.com/8aNAf.png);
background-color: none;
border: none;
}
button.green{
background-position: -3px 31px;
}
button.black{
background-position: -3px -3px;
}
<button class="green"></button>
<button class="black"></button>
Best would be to use a font like fontawesome for the icon. That way you can easily change the colour. Or use filters, see: Change color of PNG image via CSS?.
Can you link the actual image file you are using into your jsfiddle?
Try https://jsfiddle.net/35kfu6z7/1/
button em{
vertical-align:middle;
display:inline-block;
width:29px;
height:30px;
background-image: url(http://imgur.com/download/vICywDr/);
repeat:none;
}
button em.leftImage{
background-position: -28px, 0;
}
button em.rightImage{
background-position: 0, 0;
}
Same idea that #Jean-Yves Fargeat suggested(not enough rep to comment)
try this
html
<button onclick="green()";>
<div id="border">
<div id="square">
<div id="arrow"></div>
</div>
</div><span>download</span>
</button>
css
#border {
border: 2px solid black;
border-radius: 50%;
display: inline-block;
padding: 2px 6px 6px 6px;
position: relative;
top: 5px;
}
#square {
background: #000;
width: 4px;
height: 8px;
position: relative;
}
#arrow {
display: inline-block;
border: 5px solid;
border-color: black transparent transparent transparent;
position: absolute;
top: 100%;
left: -70%;
}
button span{
line-height: 30px;
margin: 5px;
}
javascript
function green() {
document.getElementById('border').style.borderColor = "green";
document.getElementById('square').style.background = "green";
document.getElementById('arrow').style.borderColor = "green transparent transparent transparent";
}
see here jsfiddle.net/hworm4/mpj47fLb/
Why not change the color of the image using photoshop?

Space between top and sub navigation

I created a navigation with a subnavigation, see JSFiddle with subnavigation. I have the issue that between the top navigation with yellow background and the subnavigation with red-colored background I want to have a distance of 1px solid white to separate both areas. At the moment this CSS definition is used
html, body {
background-color: green;
}
I tried to put another div around <nav class="top-bar" data-topbar> and set the background-color: white; but without success.
The goal is to have always a 1px solid line below the .top-bar area. So also when there is no subnavigation displayed, see JSFiddle without subnavigation, there should be this separator. I tried it to achieve it there with
.top-bar {
background: yellow;
border-bottom: 10px solid white; /*10px only to see that the border is inside the box*/
}
but the border is not outside the yellow top-bar box, it is inside, which I do not want to have. Also it would be great to have a combined so that the 1px white space between top and sb navigation is always there.
Working demo
Your border solution was almost correct, just change the box-sizing property so the border isn't placed inside the div:
.top-bar {
background: yellow; border-bottom: 10px solid white;
box-sizing: content-box;
}
This is the default value but you included Foundation that override this value with box-sizing: border-box;.
Add outer Box Shadow to your top-bar. like This:
.top-bar{
background: yellow;
box-shadow:0 0 1px #fff;
}
You can use a white border-bottom with 1px extra height on the nav:
.top-bar { height:71px; border-bottom:1px solid #fff; }
add Z-INDEX on .menu-center .active > a:before, .menu-center .active > a:after and
ul.sub-menu {
background-color: red;
display: block;
left: 0;
border-top: 1px solid #FFF;
position: absolute;
right: 0;
text-align: center;
top: 100%;
}
http://jsfiddle.net/aytaxykf/12/

How to remove bottom and right box shadow on submit button?

I have done a lot of researching on this topic and couldn't find the right answer.
I have an input button that I want to have a grey border with a white background. But when I set the background to white, it automatically creates a shadow like border on the bottom and right of the button. I can't seem a way to remove it. Below is the css code and the HTML
Any help would be really appreciated. Thanks!
CSS:
input{
display: inline-block;
height: 40px;
width: 380px;
cursor: pointer;
font-weight: bold;
font-size: 14px;
background-color: white;
}
HTML:
<input id="sign_in" type="submit" value="Sign In">
You said you want a grey border around your button but you haven't applied it in your css.
Update your css:
input{
display: inline-block;
height: 40px;
width: 380px;
cursor: pointer;
font-weight: bold;
font-size: 14px;
background-color: white;
border: 2px solid grey; /*Add your border property*/
}
Browsers add retro borders once you change the background color of a button. Fixing it is as simple as adding the following rules:
outline: 0;
border: 1px solid grey;

How to disable :hover on descendants?

Link:
http://jsbin.com/EFAlace/3/edit?html,css,output
HTML:
<a href='#' class='tooltip-parent'>Hover over me!
<span class='tooltip-container'>
<span class='tooltip'>
<a style='href='#'>Weird link</a><br>
One<br>
Two<br>
Three<br>
Four<br>
</span>
</span>
</a>
.tooltip-container added for absolute positioning, for 'reset' tooltip position.
CSS (LESS):
.tooltip-container {
position: absolute;
}
a:hover {
background-color: grey;
}
.tooltip-parent {
display: inline-block;
.tooltip {
width: 150px;
display: none;
position:relative;
border:1px solid blue;
&:before, &:after {
content: '';
top: -20px;
left: 20%;
position: absolute;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-bottom: 20px solid white;
margin-left: -20px;
}
&:before {
border-left: 23px solid transparent;
border-right: 23px solid transparent;
border-bottom: 23px solid;
margin-left: -23px;
border-bottom-color: inherit; /* Can't be included in the shorthand to work */
top: -23px;
}
}
&:hover .tooltip {
padding: 10px;
display: inline-block;
top: 20px;
}
}
ul {
list-style:none;
margin: 0; padding:0;
li {margin: 0; padding:0;}
}
:before and :after: things are for triangle at the top of the tooltip. Google on 'CSS triangle pseudo elements'
I have been experimenting with CSS-only tooltip, which pops out on hover over a parent element. You can see working example at jsBin. But I encountered the strange issue - when I add anchor inside tooltip - html markup blows out, just uncomment this code <!--<a style='href='#'>Weird link</a><br>--> in HTML pane and you will see what Im talking about. And then see at markup structure - browser just places HTML content of .tooltip outside of and element to which that tooltip is attached.
Thats pretty unclear behavior, any thoughts will be appreciated.
first i see a problem of anchor inside anchor, that's not allowed by html. try to rearrange your html tags in a better way.
secondly about the weird link, which is:
<a style='href='#'>Weird link</a>
why is it
style='href='#'