Button with multiple icons - html

I have a CSS button definition that looks like this:
.btn {
display: inline-block;
text-align: center;
vertical-align: middle;
padding: 12px 24px;
border: 1px solid #acacac;
border-radius: 8px;
background: #f5f5f5;
background: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#acacac));
background: -moz-linear-gradient(top, #f5f5f5, #acacac);
background: linear-gradient(to bottom, #f5f5f5, #acacac);
-webkit-box-shadow: #ffffff 0px 0px 40px 0px;
-moz-box-shadow: #ffffff 0px 0px 40px 0px;
box-shadow: #ffffff 0px 0px 40px 0px;
text-shadow: #ffffff 1px 1px 1px;
font: normal normal bold 20px arial;
color: #111111;
text-decoration: none;
}
.btn:hover,
.btn:focus {
border: 1px solid #f5f5f5;
background: #ffffff;
background: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#cecece));
background: -moz-linear-gradient(top, #ffffff, #cecece);
background: linear-gradient(to bottom, #ffffff, #cecece);
color: #111111;
text-decoration: none;
}
.btn:active {
background: #acacac;
background: -webkit-gradient(linear, left top, left bottom, from(#acacac), to(#acacac));
background: -moz-linear-gradient(top, #acacac, #acacac);
background: linear-gradient(to bottom, #acacac, #acacac);
}
.btn:before{
content: "\0000a0";
display: inline-block;
height: 24px;
width: 24px;
line-height: 24px;
margin: 0 4px -6px -4px;
position: relative;
top: 0px;
left: 0px;
background: url("../img/rn.png") no-repeat left center transparent;
background-size: 100% 100%;
}
I need couple of those buttons on my page but with different icons.
I tried something like this:
.client{
background: url("../img/client.png") no-repeat left center transparent;
background-size: 100% 100%;
}
.poslovnica{
background: url("../img/poslovnica.png") no-repeat left center transparent;
background-size: 100% 100%;
}
And calling it with:
<p><a class="btn client" href="#">Klijenti</a></p>
<p><a class="btn poslovnica" href="#">Poslovnice</a></p>
But that did not work.
I'm still struggling with HTML and CSS so I'd like to stay away from java, jQuery and such till I'm a bit more comfortable with HTML/CSS.
Here's a working test in jsFiddle: jsfiddle.net/8hKGf/3

Well, you are almost there... Look at this one, using your code.
http://jsfiddle.net/fg7Ya/
It will output the same image for each button.
If we go further, we get this:
http://jsfiddle.net/fg7Ya/2/
Which is this, in short:
.btn.client:before {
background: url("http://www.klm.com/jobs/nl/images/icon_updateprofile_tcm701-313773.gif") no-repeat left center transparent;
}
.btn.poslovnica:before {
background: url("http://www.dhl.nl/content/dam/General%20DHL%20pictures/Icons/Small%20teasers_50x50/dhl_open_account_icon_42x40.jpg") no-repeat left center transparent;
}

If I got you right, you want to keep your gradient and have those icons within your button? If so, use background-image for your icons. This will keep the background gradient:
Fiddle
.client{
background-image: url("../img/client.png") no-repeat left center transparent;
background-size: 100% 100%;
}
.poslovnica{
background-image: url("../img/poslovnica.png") no-repeat left center transparent;
background-size: 100% 100%;
}
Moreover, you schould remove the <p> Tag from the anchor.

you just need your background-size this will keep background color.
check out this fiddle :
http://jsfiddle.net/C45ks/
.client{
background: url("http://upload.wikimedia.org/wikipedia/commons/a/ac/Approve_icon.svg")
no-repeat left center transparent;
**background-size: 20% 60%;**
}
.poslovnica{
background: url("http://upload.wikimedia.org/wikipedia/commons/a/ac/Approve_icon.svg")
no-repeat left center transparent;
**background-size: 20% 60%;**
}

Related

Override div style link color in css

I'm placing a button (created by a css) in my html page.
Currently this button inherits the link color from the div.
I'm trying to override these link colors and make the button show a link in a different color.
I have created a button style in the css file like this, and I was pretty sure by specifying the link colors in the button, I would automatically override the div link colors.
.button {
display: inline-block;
padding: 0 14px;
margin: 8px 0 0;
height: 32px;
line-height: 32px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
text-decoration: none;
position: relative;
overflow: hidden;
vertical-align: top;
color: #fff;
background: #49b1fb;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #5196d5), color-stop(1, #49b1fb));
background: -ms-linear-gradient(bottom, #5196d5, #49b1fb);
background: -moz-linear-gradient(center bottom, #5196d5 0%, #49b1fb 100%);
border-bottom: 1px solid #4c8cc8;
link {text-decoration: none; color: #FFF;}
visited {text-decoration: none; color: #FFF;}
hover {text-decoration: none; color: #FFF;}
active {text-decoration: none; color: #FFF;}
}
I use the button like this:
<div id="widecontent">
<div id="content">
<div id="content-inner">
<div class="column_left">
<h2>Download</h2>Click below to download the app:
<br/>
Download
</div>
However, the link color of the button is the same as the div style.
The link colors as I have defined them in the css file don't show an effect.
What is the correct way to override the link color of the div / what am I doing incorrectly?
You should define it like this for hover for example:
.button {
display: inline-block;
padding: 0 14px;
margin: 8px 0 0;
height: 32px;
line-height: 32px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
text-decoration: none;
position: relative;
overflow: hidden;
vertical-align: top;
color: #fff;
background: #49b1fb;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #5196d5), color-stop(1, #49b1fb));
background: -ms-linear-gradient(bottom, #5196d5, #49b1fb);
background: -moz-linear-gradient(center bottom, #5196d5 0%, #49b1fb 100%);
border-bottom: 1px solid #4c8cc8;
}
.button:hover {
text-decoration: none;
color: #FFF;
}
you are confusing properties with pseudo-classes (:active/:hover and etc)
so you should use them outside of the rule, and not inside.
.button {
display: inline-block;
padding: 0 14px;
margin: 8px 0 0;
height: 32px;
line-height: 32px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
text-decoration: none;
position: relative;
overflow: hidden;
vertical-align: top;
color: #fff;
background: #49b1fb;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #5196d5), color-stop(1, #49b1fb));
background: -ms-linear-gradient(bottom, #5196d5, #49b1fb);
background: -moz-linear-gradient(center bottom, #5196d5 0%, #49b1fb 100%);
border-bottom: 1px solid #4c8cc8;
}
.button:visited {
color: green
}
.button:focus {
color: purple
}
.button:hover {
color: red
}
.button:active {
color: yellow
}
I use the button like this:
<div id="widecontent">
<div id="content">
<div id="content-inner">
<div class="column_left">
<h2>Download</h2>Click below to download the app:
<br/>
Download
</div>

horizontal and vertical lines in a square

Below is the image I am trying for, I managed to get a square using CSS, but I am trying for horizontal and vertical line in a square.
.hub{
width: 119px;
height: 101px;
background: #b5adad;
}
<div class="hub"></div>
There are many ways to do this and one would be to use gradients like below: (the image in question was actually a rectangle.)
The approach is very simple - we use 2 linear gradients to create two thin solid colored lines and then position the images such that they match our needs. Linear gradients are used even though it creates only a solid color because it is easier to control size and position of an image than background color.
div {
height: 100px;
width: 200px;
border: 1px solid red;
background-image: linear-gradient(to bottom, red, red), linear-gradient(to right, red, red);
background-repeat: no-repeat;
background-size: 1px 100%, 100% 1px;
background-position: 20px 0px, 0px 10px;
}
<div></div>
We can also create an output which has a fade-out or shadow effect like in the image in question:
div {
height: 100px;
width: 200px;
border: 1px solid;
background-color: gray;
background-image: linear-gradient(to bottom, black, black), linear-gradient(to right, red, transparent), linear-gradient(to right, black, black), linear-gradient(to bottom, red, transparent);
background-repeat: no-repeat;
background-size: 1px 100%, 1px 100%, 100% 1px, 100% 1px;
background-position: 20px 0px, 21px 0px, 0px 10px, 0px 11px;
box-shadow: inset 0px 0px 3px red;
}
<div></div>
Another way is to use :before and :after pseudo-elements:
.hub{
width: 119px;
height: 101px;
background: #b5adad;
position: relative;
padding: 18px 0 0 18px;
}
.hub:after, .hub:before {
content: " ";
background: black;
display: block;
position: absolute;
}
.hub:after {
width: 1px;
height: 100%;
left: 15px;
top: 0;
}
.hub:before {
width: 100%;
height: 1px;
top: 15px;
left: 0;
}
<div class="hub">Lorem ipsum dolor amet</div>

How to keep a row of buttons neatly spaced on a small screen

If the html code below is run on a small screen, one or more buttons will naturally move on to the "lower line", adjusting to screen size. In principle that's great but unfortunately any button moving from the row will be glued to a button above. That... is ugly and less functional.
How can I space them vertically?
<style>
.button {
background: #fcfcfc;
background-image: -webkit-linear-gradient(top, #fcfcfc, #d6d6d6);
background-image: -moz-linear-gradient(top, #fcfcfc, #d6d6d6);
background-image: -ms-linear-gradient(top, #fcfcfc, #d6d6d6);
background-image: -o-linear-gradient(top, #fcfcfc, #d6d6d6);
background-image: linear-gradient(to bottom, #fcfcfc, #d6d6d6);
font: large;
color: ButtonText;
display: inline-block;
padding: 5px 12px 5px 12px;
border: solid #b8a8a8 1px;
text-decoration: none;
}
.button:hover {
border: solid #7b6b6b 1px;
text-decoration: none;
}
</style>
<center>
<div class="container">
Archive 1
Archive 2
Archive 3
Archive 4
</div>
</center>
You're attempting to affect spacing on an inline element (the anchor tag) which isn't as clear-cut as a block element (list item for instance). Try wrapping your anchor tags in a block element and apply the style to the wrapping object.
Have a look at this post for reference: Padding for Inline Elements
.button {
background: #fcfcfc;
background-image: -webkit-linear-gradient(top, #fcfcfc, #d6d6d6);
background-image: -moz-linear-gradient(top, #fcfcfc, #d6d6d6);
background-image: -ms-linear-gradient(top, #fcfcfc, #d6d6d6);
background-image: -o-linear-gradient(top, #fcfcfc, #d6d6d6);
background-image: linear-gradient(to bottom, #fcfcfc, #d6d6d6);
font: large;
color: ButtonText;
display: inline-block;
padding: 5px 12px 5px 12px;
border: solid #b8a8a8 1px;
text-decoration: none;
}
.button:hover {
border: solid #7b6b6b 1px;
text-decoration: none;
}
#media screen and (max-width: 480px) {
.button {
display: block;
width: 200px;
}
}
<center>
<div class="container">
Archive 1
Archive 2
Archive 3
Archive 4
</div>
</center>
Thanks to #DanielC for his link I could find the solution. Very simply you only have to add margin definitions on .button styling. That way the buttons are always neatly arranged, no matter the size of the screen! 8-)
<style>
.button {
background: #fcfcfc;
background-image: -webkit-linear-gradient(top, #fcfcfc, #d6d6d6);
background-image: -moz-linear-gradient(top, #fcfcfc, #d6d6d6);
background-image: -ms-linear-gradient(top, #fcfcfc, #d6d6d6);
background-image: -o-linear-gradient(top, #fcfcfc, #d6d6d6);
background-image: linear-gradient(to bottom, #fcfcfc, #d6d6d6);
font: large;
color: ButtonText;
display: inline-block;
padding: 5px 12px 5px 12px;
margin: 5px 5px 5px 5px;
border: solid #b8a8a8 1px;
text-decoration: none;
}
.button:hover {
border: solid #7b6b6b 1px;
text-decoration: none;
}
</style>
<center>
<div class="container">
Archive 1
Archive 2
Archive 3
Archive 4
</div>
</center>

Brackets input CSS

I am developing a phonegap App for Android containing a form.
HTML :
<input class="holo">
Here problem is that the input tag has not applied with CSS style in my Samsung Galaxy Pocket (4.0.4). But in Moto G (KitKat 4.4.2) works fine!!
CSS I used:
input.holo {
width: 100%;
height: 30px;
font-family: "Roboto", "Droid Sans", sans-serif;
margin: 0;
padding: 8px 8px 6px 8px;
display: block;
outline: none;
border: none;
background: bottom left linear-gradient(#09c, #09c) no-repeat, bottom center linear-gradient(#09c, #09c) repeat-x, bottom right linear-gradient(#09c, #09c) no-repeat;
background-size: 1px 6px, 1px 1px, 1px 6px;
}
input.holo:disabled{
background: #e8e8e8
}
input.holo:disabled:hover{
background: #e8e8e8
}
input.holo:hover, input.holo:focus {
background: bottom left linear-gradient(#09c, #09c) no-repeat, bottom center linear-gradient(#09c, #09c) repeat-x, bottom right linear-gradient(#09c, #09c) no-repeat;
background-size: 1px 6px, 1px 1px, 1px 6px;
}
Thanks.
PS: In Chrome works fine!!
http://jsfiddle.net/GLVc8/

I need assistance with my css, to obtain Content over display block. This is needed to add a title

Here is my HTML
<div class="about-buttonback"><div class="about-button"></div></div>
Here is the CSS:
.about-button {
color:#fff;
content: "Calender";
Display: block;
position: absolute;
width: 860px;
height: 40px;
top:5px;
left:5px;
text-indent: -9999px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
background-color: #d1d2d4;
background-image: -webkit-gradient(linear, left top, left bottom, from(#323232), to(#2a2829));
background-image: -webkit-linear-gradient(top, #000, #2a2829);
background-image: -moz-linear-gradient(top, #000, #2a2829);
background-image: -o-linear-gradient(top, #000, #2a2829);
background-image: linear-gradient(to bottom, #000, #2a2829);
box-shadow: 1px 1px 1px #000;
}
.about-buttonback {
display: block;
position: absolute;
width: 870px;
height: 50px;
top:0px;
left: 35px;
text-indent: -9999px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
background-color: #d1d2d4;
background-image: -webkit-gradient(linear, left top, left bottom, from(#6b6b6b), to(#000));
background-image: -webkit-linear-gradient(top, #4b4b4b, #000);
background-image: -moz-linear-gradient(top, #4b4b4b, #000);
background-image: -o-linear-gradient(top, #4b4b4b, #000);
background-image: linear-gradient(to bottom, #4b4b4b, #000);
}
I am trying to do more over a overlay with a title over the blocks. I need the content to say Calender but it is not showing up over the blocks. Any suggestions?
Thank you so much for the help!
First of all you won't need display: block;, and secondly, you are not able to see the text because you are using text-indent: -9999px which will just move any text in that block out of the viewport.
Demo
Also, make sure you wrap the position: absolute; elements under position: relative; container, else they will mess up your layout.
Do this thing :-
Fiddle
<div class="about-button">Calendar</div>
you need the content to say Calender over the blocks for that if you add any text in Div
let's say "**<div class="about-button">Calendar </div>**" but text will not going to show after this too because you added " text-indent: -9999px; " to the both of the classes which you should need to remove in order to let your text display over the blocks.