It seems that I can't get the hang of this, and ugh it's pretty frustrating.
This is a similar question to my previous question here.
http://jsfiddle.net/bm33e/
How would I get the red dot in vertically middle relative to the text? I've tried solutions and slight variations but couldn't get it working.
CSS
body { padding: 50px; background-color: #222; }
.led {
display: table-cell;
width: 16px;
height: 16px;
border-radius: 50%;
float: left;
}
.led-red {
background-color: #ED3029;
box-shadow: #000 0 -1px 6px 1px, inset #920 0 -1px 8px, #ED3029 0 3px 11px;
}
.led-green {
background-color: #00A448;
box-shadow: #000 0 -1px 6px 1px, inset #490 0 -1px 8px, #00A448 0 3px 11px;
}
.hi {
max-width: 40%;
-moz-box-shadow:inset 0px 0px 0px 0px #646464;
-webkit-box-shadow:inset 0px 0px 0px 0px #646464;
box-shadow:inset 0px 0px 0px 0px #646464;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #707070), color-stop(1, #646464));
background:-moz-linear-gradient(top, #707070 5%, #646464 100%);
background:-webkit-linear-gradient(top, #707070 5%, #646464 100%);
background:-o-linear-gradient(top, #707070 5%, #646464 100%);
background:-ms-linear-gradient(top, #707070 5%, #646464 100%);
background:linear-gradient(to bottom, #707070 5%, #646464 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#707070', endColorstr='#646464',GradientType=0);
background-color:#707070;
-moz-border-radius:4px;
-webkit-border-radius:4px;
border-radius:4px;
cursor:pointer;
color:#ffffff;
font-size:40px;
font-weight:bold;
padding:14px 20px;
text-align: right;
height: auto;
}
HTML
<div class="hi">
<div class="led led-red" vertical-align="middle">
</div>
Deluxe
</div>
Thanks again stackoverflow helpers :)
Since your div.hi has relative position and your .led height is constant, you can absolutely position .led and use calc() to center it:
.led{
position: absolute;
top: calc(50% - 8px);
}
JSFiddle
Note: this is a css3 solution is not compatible in really old browsers
if you don't mind unloading some of that css.
I would use the inline-block property on that div. I think its more aptly done that way.
.led {display:inline-block;}
http://jsfiddle.net/bm33e/4/
Related
I am trying to add some css to my button and for some reason this is not working.
Index page
<input style="margin-top:10px;" type="submit" class="loginButton" title="Subscribe" value="Subscribe" />
CSS
.loginButton {
-moz-box-shadow: 0px 0px 0px 1px #ffffff;
-webkit-box-shadow: 0px 0px 0px 1px #ffffff;
box-shadow: 0px 0px 0px 1px #ffffff;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #9e0000), color-stop(1, #ff0000));
background: -moz-linear-gradient(top, #9e0000 5%, #ff0000 100%);
background: -webkit-linear-gradient(top, #9e0000 5%, #ff0000 100%);
background: -o-linear-gradient(top, #9e0000 5%, #ff0000 100%);
background: -ms-linear-gradient(top, #9e0000 5%, #ff0000 100%);
background: linear-gradient(to bottom, #9e0000 5%, #ff0000 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#9e0000', endColorstr='#ff0000',GradientType=0);
background-color: #9e0000;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
border: 1px solid #1c0101;
display: inline-block;
cursor: pointer;
color: #ffffff;
font-family: Trebuchet MS;
font-size: 18px;
padding: 18px 44px;
text-decoration: none;
text-shadow: 0px 1px 0px #000000;
}
What could this be? as I used this style before.
It works pretty well for me
Double check your CSS paths and class hierarchy.
It's working. Make sure to include the correct path for external CSS or if you are using inside the html file, make sure to mention the css script inside
<style type="text/css"></style>
https://i.stack.imgur.com/NkrJ8.jpg
Hi it is working fine and please double check you code, if not just add the css class as shown below (add the class with input)
input.loginButton{ /*HERE YOU CAN ADD YOUR CSS CODE*/}
Hello I've created a webpage with a banner on it and a button is centered under the banner. When I go to access my website on a large screen the banner resizes to fit the screen but the button stays the same size. I've tried looking for an answer but could not find it.
Here is my code:
HTML
<a href='http://www.aporiagrand.com/shop/' class='button'>SHOP</a>
CSS
.button {
border: 2px solid #ffffff;
background: #000000;
background: -webkit-gradient(linear, left top, left bottom, from(#000000), to(#000000));
background: -webkit-linear-gradient(top, #000000, #000000);
background: -moz-linear-gradient(top, #000000, #000000);
background: -ms-linear-gradient(top, #000000, #000000);
background: -o-linear-gradient(top, #000000, #000000);
background-image: -ms-linear-gradient(top, #000000 0%, #000000 100%);
padding: 12px 24px;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
border-radius: 0px;
-webkit-box-shadow: rgba(255,255,255,0.4) 0 0px 0, inset rgba(255,255,255,0.4) 0 0px 0;
-moz-box-shadow: rgba(255,255,255,0.4) 0 0px 0, inset rgba(255,255,255,0.4) 0 0px 0;
box-shadow: rgba(255,255,255,0.4) 0 0px 0, inset rgba(255,255,255,0.4) 0 0px 0;
text-shadow: #000000 0 1px 0;
color: #ffffff;
font-size: 18px;
font-family: helvetica, serif;
text-decoration: none;
vertical-align: center;
position:relative;
transition: .5s ease;
top: 1px;
left: 45%;
right: -45%;
bottom: -20%;
}
.button:hover {
border: 2px solid #ffffff;
text-shadow: #ffffff 0 1px 0;
background: #ffffff;
background: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#ffffff));
background: -webkit-linear-gradient(top, #ffffff, #ffffff);
background: -moz-linear-gradient(top, #ffffff, #ffffff);
background: -ms-linear-gradient(top, #ffffff, #ffffff);
background: -o-linear-gradient(top, #ffffff, #ffffff);
background-image: -ms-linear-gradient(top, #ffffff 0%, #ffffff 100%);
color: #000000;
}
.button:active {
text-shadow: #dbdbdb 0 1px 0;
border: 2px solid #dbdbdb;
background: #dbdbdb;
background: -webkit-gradient(linear, left top, left bottom, from(#dbdbdb), to(#ffffff));
background: -webkit-linear-gradient(top, #dbdbdb, #dbdbdb);
background: -ms-linear-gradient(top, #dbdbdb, #dbdbdb);
background: -o-linear-gradient(top, #dbdbdb, #dbdbdb);
background-image: -ms-linear-gradient(top, #dbdbdb 0%, #dbdbdb 100%);
color: #dbdbdb;
}
I assume you are using this
position:relative;
transition: .5s ease;
top: 1px;
left: 45%;
right: -45%;
bottom: -20%;
as a way to center your button; might I suggest instead you try to use something along the lines of:
margin: 0 auto; max-width:25%; text-align:center;
Your button currently won't scale with your site as I believe the only thing giving it any size is the padding you've applied. Using percentages is generally a good way to deal with these kind of issues.
I noticed that your font-size for the button in css is fixed, so the button size is not being small in small screens.
See this code:
1vw = 1% of viewport width
1vh = 1% of viewport height
1vmin = 1vw or 1vh, whichever is smaller
1vmax = 1vw or 1vh, whichever is larger
in stackoverflow link
and try changing font-size:18px; to something like font-size: 4.0vw; according to your requirements.
I am trying to create a button similar to this in CSS3. (all HTML5 browsers should be supported):
Button image
HTML:
<div class="buttonClass">Nitin Mukesh</div>
CSS:
body {
background: gray;
margin-top: 50px;
margin-left: 50px;
}
.buttonClass {
width: 300px;
height: 40px;
padding: 10px 60px;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
border-radius: 7px;
background: -moz-linear-gradient(top, #FFFFFF 0%, #91BDD6 100%); /* firefox */
border: solid #91BDD6 5px;
outline: solid #fff 5px;
-moz-box-shadow: 3px 1px 24px #000000;
-webkit-box-shadow: 3px 1px 24px #000000;
box-shadow: 3px 1px 24px #000000;
}
JSFiddle
I could possible think of a solution that using 2 div will solve the problem with outer div hold the white outline and box-shadow and inner div with outline and gradient color.
Is it possible to achieve this using single div.
Many thanks for any inputs
This is what I came up with: http://jsfiddle.net/psycketom/heGu9/2/
.button
{
display: block;
background-image: linear-gradient(bottom, rgb(145,189,214) 0%, rgb(255,255,255) 100%);
background-image: -o-linear-gradient(bottom, rgb(145,189,214) 0%, rgb(255,255,255) 100%);
background-image: -moz-linear-gradient(bottom, rgb(145,189,214) 0%, rgb(255,255,255) 100%);
background-image: -webkit-linear-gradient(bottom, rgb(145,189,214) 0%, rgb(255,255,255) 100%);
background-image: -ms-linear-gradient(bottom, rgb(145,189,214) 0%, rgb(255,255,255) 100%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0, rgb(145,189,214)),
color-stop(1, rgb(255,255,255))
);
/* Added second shadow for that "black" effect */
box-shadow: 0px 0px 0px 5px white, 0px 0px 10px 5px black;
-o-box-shadow: 0px 0px 0px 5px white, 0px 0px 10px 5px black;
-ms-box-shadow: 0px 0px 0px 5px white, 0px 0px 10px 5px black;
-moz-box-shadow: 0px 0px 0px 5px white, 0px 0px 10px 5px black;
-webkit-box-shadow: 0px 0px 0px 5px white, 0px 0px 10px 5px black;
border-radius: 15px;
-o-border-radius: 15px;
-ms-border-radius: 15px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border: solid 5px rgb(145,189,214);
padding: 60px;
margin: 7px; /* to complement the outside shadow */
}
box-shadow can have multiple shadow, so:
http://jsfiddle.net/cyzw8/4/
.buttonClass {
width: 200px;
height: 40px;
/* padding: 10px 60px;*/
text-align:center;
line-height:40px;
border-radius: 7px;
background-image:-webkit-linear-gradient(top,#FFF 0%,#91BDD6 100%);
background-image: -moz-linear-gradient(top, #FFFFFF 0%, #91BDD6 100%);
background-image:-ms-linear-gradient(top,#FFF,#91BDD6);
background-image:-o-linear-gradient(top,#FFF,#91BDD6);
background-image:linear-gradient(top,#FFF,#91BDD6);
border: solid #91BDD6 5px;
box-shadow: 0px 0px 0px 5px #fff, 5px 3px 12px #000000;
}
This is what I see in my Chrome:
Here is a second way http://jsfiddle.net/Merec/Va4qG/
<div class="buttonClass"><span>Nitin Mukesh</span></div>
.buttonClass {
display: inline-block;
background: #fff;
border: 2px solid #fff;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background: rgb(255,255,255); /* Old browsers */
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(145,189,214,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(145,189,214,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(145,189,214,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(145,189,214,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(145,189,214,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(145,189,214,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#91bdd6',GradientType=0 ); /* IE6-9 */
}
.buttonClass span {
padding: 5px 10px;
display: block;
border: 2px solid #91bdd6;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
I've got this image:
I want to code this image (just the bar, not the background - background can change) using html and css3. It has to be scalable in height and width. What's the best technique to do that? Thanks.
OK you can try this (tested in Firefox 11 only)...
HTML
<div class="bubble">
<div class="content">
Some content can go inside this bubble...
</div>
<div class="arrow"><div class="arrow-shadow"></div></div>
</div>
CSS
.bubble
{
background:#D0D0D0;
background-image: -ms-linear-gradient(top, #BBB 0%, #EEE 100%);
background-image: -moz-linear-gradient(top, #BBB 0%, #EEE 100%);
background-image: -o-linear-gradient(top, #BBB 0%, #EEE 100%);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #BBB), color-stop(1, #EEE));
background-image: -webkit-linear-gradient(top, #BBB 0%, #EEE 100%);
background-image: linear-gradient(top, #BBB 0%, #EEE 100%);
border-radius:10px;
border-top:2px solid #EEE;
border-bottom:2px solid #AAA;
position:relative;
width:380px;
height:100px;
}
.bubble .content
{
padding:10px;
}
/* Arrow */
.bubble .arrow {
position:absolute;
top:50%;
left:100%;
margin-top:-12px;
}
.bubble .arrow:after,
.arrow .arrow-shadow
{
border:10px solid Transparent;
border-color:rgba(255,255,255,0) rgba(255,255,255,0) rgba(255,255,255,0) rgba(255,255,255,0);
content:' ';
height:0;
position:absolute;
width:0;
}
.bubble .arrow:after
{
border-left-color:#D3D3D3;
}
.arrow .arrow-shadow
{
height:3px;
border-left-color:#AAA;
}
It's a bit of a hack in my opinion, but it seems to get fairly close to what you want. The only things that may be an issue are:
Backwards compatibility. Older versions of IE might choke so it'd be worth testing it and hacking IE compatibility as required.
If the box becomes too big, the arrow might look a different colour to the box. I can't figure out a way around this, so you might have better results putting the arrow in a static location.
You can find a JSFiddle here: http://jsfiddle.net/eWj6q/13/
I may not recommend it the best technique but somehow it will work better:
Using linear gradients: A linear gradient is one that gradually transitions between colours over the distance between two points in a straight line. At its simplest, a linear gradient will change proportionally between two colours along the full length of the line.
div {
background: -moz-linear-gradient(#FFF, #000);
background: -ms-linear-gradient(#FFF, #000);
background: -o-linear-gradient(#FFF, #000);
background: -webkit-linear-gradient(#FFF, #000);
}
This is closest I could get using div's.
Probably could get the arrow better by using canvas, but it would require javascript.
Javascript would also sovle the background color problem for the arrowish-like box. :)
Demo: http://jsfiddle.net/Xvm2C/
Screenshot: http://i.stack.imgur.com/iwlMj.png
HTML part:
<div class="nice">
<div class="arrow-container">
</div>
Hello world!
</div>
CSS part:
body {padding:50px; background-color: #ccc;}
.nice {
background-color: white;
position: relative;
min-height:65px;
padding:10px 10px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background: -moz-linear-gradient(top, #cccccc 0%, #ffffff 100%); /* firefox */
box-shadow: 0 0px 0px #fff, 0 0px 1px #666, inset -1px -1px 0px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.8);
-moz-box-shadow: 0 0 0 #FFFFFF, 0 0 1px #666666, -1px -1px 0 rgba(0, 0, 0, 0.5) inset, 0 1px 1px rgba(255, 255, 255, 0.8) inset;
-webkit-box-shadow: 0 0px 0px #fff, 0 0px 1px #666, inset -1px -1px 0px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.8);
text-shadow: 0 1px 2px #fff;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#cccccc), color-stop(100%,#ffffff));
font-size:20px
}
.arrow-container {
background-color: white;
height: 26px;
position: absolute;
right: 0;
top: 50%;
margin-top:-13px;
margin-right:-19px;
width: 20px;
background: -moz-linear-gradient(top, #dcdcdc 0%, #ededed 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#dcdcdc), color-stop(100%,#ededed));
box-shadow: 0 0px 0px #fff, 1px 0px 1px #666, inset 0px -1px 0px rgba(0,0,0,0.5), inset -1px 1px 1px rgba(255,255,255,0.8);
-moz-box-shadow: 0 0 0 #FFFFFF, 1px 0 1px #666666, 0px -1px 0 rgba(0, 0, 0, 0.5) inset, -1px 1px 1px rgba(255, 255, 255, 0.8) inset;
-webkit-box-shadow: 0 0px 0px #fff, 1px 0px 1px #666, inset 0px -1px 0px rgba(0,0,0,0.5), inset -1px 1px 1px rgba(255,255,255,0.8);
-webkit-border-top-right-radius: 7px;
-moz-border-top-right-radius: 7px;
border-top-right-radius: 7px;
-webkit-border-bottom-right-radius: 25px;
-moz-border-bottom-right-radius: 25px;
border-bottom-right-radius: 25px;
}
I have been making a button which (hopefully) looks fairly realistic. One part of this is having the text move down 1px inside the button when it is pressed. I've done this by adding an additional pixel to the top and removing one from the bottom.
Unfortunately, I've designed my button to work inline (inline-block) and when the button is "pushed" it means any text on the line also gets pushed down. Now I think I know why (presumably due to the baseline of the text) but I wonder if anyone knows how I can get the same "pushed" effect whilst keeping surrounding text in place. I would like to avoid floats if possible.
Anyway on with the code:
http://gard.me/xsfqH
HTML:
<a class="button noIcon smaller" href="#">Buy Now</a> hello world
CSS:
a.button {
margin: 20px;
display: inline-block;
padding: 12px 12px 12px 12px;
background: none;
background-repeat: no-repeat;
background-position: 9px 5px;
background-position: 9px 5px, 0 0;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
border-width: 1px;
border-style: solid;
font-family: Verdana, Arial, Sans-Serif;
text-decoration: none;
}
a.button:active {
padding-top: 13px; padding-bottom: 11px;
-webkit-box-shadow: inset 0px 1px 6px -1px #000000;
-moz-box-shadow: inset 0px 1px 6px -1px #000000;
box-shadow: inset 0px 1px 6px -1px #000000;
}
a.button.noIcon {
color: #FFECEA;
background-position: 0 0;
background-color: #E46553;
background-image: -o-linear-gradient(bottom, #D15039 0%, #F27466 100%);
background-image: -moz-linear-gradient(bottom, #D15039 0%, #F27466 100%);
background-image: -webkit-linear-gradient(bottom, #D15039 0%, #F27466 100%);
background-image: -ms-linear-gradient(bottom, #D15039 0%, #F27466 100%);
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #D15039), color-stop(1, #F27466));
border-color: #A03E33;
}
since it's inline-block you can use vertical-align.
so all you have to do is
a.button:active {
padding-top: 13px;padding-top:11px;
-webkit-box-shadow: inset 0px 1px 6px -1px #000000;
-moz-box-shadow: inset 0px 1px 6px -1px #000000;
box-shadow: inset 0px 1px 6px -1px #000000;
vertical-align:1px;
}
and problem solved