How to do this kind of Button in CSS?
Tags: css,button,css-shapes
Problem :
I've been searching the Internet for a while and found nothing, so I'm turning to you guys.
I was wondering how you can do a button like this with CSS (On/Off button example):
I already tried something like this :
HTML :
<a class="button_tooltip" href="#">On</a>
<a class="button_tooltip" href="#">Off</a>
CSS:
a {
color: #76daff;
display: inline-block;
padding: 8px 16px;
position: relative;
text-decoration: none;
}
a {
color: #76daff;
}
a.button_tooltip {
background: #ccc none repeat scroll 0 0;
color: black;
}
a.button_tooltip::after {
border-top-color: #cccccc;
}
a.button_tooltip::after {
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid #ccc;
content: "";
margin-left: -8px;
}
a.button_tooltip {
background: #cccccc none repeat scroll 0 0;
color: #000000;
}
a.button_tooltip::after {
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid #ccc;
content: "";
}
a.button_tooltip::after {
border-top-color: #cccccc;
}
But only gave me the square without the little triangle underneath.
Solution :
This is easily possible with 2 elements and using a pseudo element to get the arrow bit underneath to show.
It doesn't take a great deal of HTML/CSS to complete and can easily be changed to work as an input or as an <a>
tag. Whatever your requirements are.
$(document).ready(function() {
$('.btn').click(function() {
$('.btn').toggleClass('active');
});
});
.container {
width: 200px;
height: 100px;
}
.btn {
width: 100px;
height: 100px;
box-sizing: border-box;
border: 1px solid blue;
float: left;
cursor: pointer;
}
.active {
background: blue;
position: relative;
}
.active:before {
content: '';
position: absolute;
width: 50px;
height: 50px;
transform: rotate(45deg);
bottom: -10px;
left: 25px;
background: blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="btn"></div>
<div class="btn active"></div>
</div>
CSS Howto..
Yes: div.your-style > textarea{ height: 60px; } ...
To move something behind the other you need to give it a z-index that is lower than the other element, in this case I gave the strike a z-index of...
Here you go. WORKING DEMO The Code Change: <img src="http://www.aroose-shahkar.com/images/ribbon.png" style=" left: 155px; margin-left: -73px; margin-top: -99px; position: relative; top: -99px;" /> Hope this is what you are looking for....
it is not possible in pure css. if you use some css templater language like Sass, you could use @extend for this purpose. however in fact it will just produce...
ul { width: 500px; display: table; } li { display: table-cell; } Here's the fiddle: http://jsfiddle.net/WhbuQ/...
<div class="alert alert-warning alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert"> <span aria-hidden="true">×</span><span class="sr-only">Close</span> </button> <strong>Warning!</strong> Better check yourself,...
<%=Html.TextBox("termino", "", new { @class = "redborder" }) %> ...
I don't get why you can not just insert the <link/> element in the <head/> section, but here's a jQuery snippet: $('head').append( $('<link rel="stylesheet" type="text/css" />').attr('href', 'your stylesheet url') );...
I assume that your login form has an external CSS file, and that you're using Cassini or IIS 7 integrated mode. Your <deny users="?"/> is preventing anonymous users from seeing...
The following works for me. $("#myElement").css({ background: "-webkit-gradient(linear, left top, left bottom, from(#000000), to(#FFFFFF))"}).css({ background: "-moz-linear-gradient(top, black, white)" }); jsFiddle Demo Changes: background instead of backgroundImage top, bottom to: left...
I would suggest to create a class with name like .active and then use .addClass method. However take a look at the DEMO first. Here is the jQuery Code $('.active').css({...
Add this row of css ul#topnav li:hover a { color: #828282; } ...
While the hasome class is applied to the parent div, it's used in a selector that's setting CSS values on the child span. So in Firebug (or Chrome or IE's...
In your style.cssfile try adding the following and see what happends: @media print { body { border: 15px solid black; } } You have to use @media print to apply...
I switched out the div for a span (although an anchor link would probably be better if it's clickable) JSFiddle Demo HTML <ol> <li> <span class="button speaker"></span> Lorem ipsum dolor...
is there a possibility to use a selector which defines a group of colors which are close to black No. Selectors doesn't have any knowledge of color whatsoever. You're...
You can define similar css at one place with joining multiple selectors and overriding later if necessary: Note: The styles that you are overriding i.e for .error and .success must...
The most obvious solution is just to close the container...have your full width div then open a new container. The title 'container' is just a class...not an absolute requirement that...
It is because of the width of your images you are using for the background, it works fine if you have the inputs the same width as the images. FIDDLE...
demo jsBin Add this lines and play around: CSS: ul.semiopaquemenu > li > ul{ background:#ccc; padding:15px 20px; } ul.semiopaquemenu > li > ul li { color:white; cursor:pointer; display:block; padding:4px 10px;...
That inline is causing it. Remove the class from the inner div, and add the following: .store-display-item div { width: 100px; } <li class="store-display-item"> <div> <img class="store-display-image" src="/Images/ToughBook.jpg"> <p>QuickTrav Carbon...
.nav-sec-level{ background: red; border:1px solid #000; display: none; } .side-bar:hover .nav-sec-level{ display: block; } <ul> <li class="side-bar"> <a>gh kl</a> <ul class="nav-sec-level">some menu <li>jdfs</li> <li>jdfs</li> <li>jdfs</li> </ul>...
Rails 2.3 does not have asset pipeline. So there is no need to precompile assets. Your assets should already be located in the Rails.root/public/stylesheets folder Anything in Rails.root/public/ folder is...
Try this ..... document.getElementById("myForm").reset(); ...
You should use an (non-breaking space) character in between the words to indicate that lines should not break there. Example: <h2>John Smith Fine Art</h2>...
To fix it, find the specific style property(properties) in the body that affect your date picker and then specifically reset those properties in the datepicker css. eg /main.css/ body{ font-size:...
Assuming your desired width/height and overflow: hidden is applied to an outer containing div, you can add something like: .container img { position: relative; top: 50%; transform: translateY(-50%); } This...
You cannot select an element with CSS selectors on the basis of its children. Neither is such selection needed, if you wish to simulate the effect of a placeholder attribute...
Very simple, you can create a toggleColors function to change the colors each x time. JavaScript: // Globar vars var timer; var miliseconds = 500; /** * Function to toggle...
Bind an event on scroll of window, and set the position of target div, based on the scrolltop of window. $(window).scroll(function () { if($(this).scrollTop() >= 500){ $('targetdiv').css('position','fixed'); } else {...