The top of the button seems to have a default shadow when clicked you can see in the Codepen example the gold border gets darker around the top rim - how do I remove this behaviour?
Example
.button {
cursor:pointer;
height: 3rem;
width:10rem;
margin:15px;
font-size:2em;
font-family: Helvetica, Arial, Sans-Serif;
background: linear-gradient(to bottom, rgba(76,76,76,1) 0%,rgba(89,89,89,1) 9%,rgba(102,102,102,1) 20%,rgba(71,71,71,1) 34%,rgba(71,71,71,1) 34%,rgba(44,44,44,1) 45%,rgba(0,0,0,1) 54%,rgba(17,17,17,1) 60%,rgba(43,43,43,1) 76%,rgba(28,28,28,1) 91%,rgba(19,19,19,1) 100%);
text-decoration:none;
border-radius:10rem;
border-color:#fcbd3f ;
border-width: 1.5px;
color:#d4d6d8 ;
box-shadow: 0px 17px 10px -10px rgba(0,0,0,0.4);
outline: none;
&:active{
outline: none;
box-shadow: inset 0px 7px 10px -10px;
background: linear-gradient(to bottom, rgba(76,76,76,1) 0%,rgba(0,0,0,1) 16%,rgba(17,17,17,1) 51%,rgba(28,28,28,1) 70%,rgba(28,28,28,1) 70%,rgba(44,44,44,1) 82%,rgba(43,43,43,1) 82%,rgba(56,56,56,1) 82%,rgba(44,44,44,1) 82%,rgba(66,66,66,1) 84%,rgba(84,84,84,1) 91%,rgba(109,109,109,1) 92%,rgba(102,102,102,1) 98%,rgba(28,28,28,1) 100%,rgba(19,19,19,1) 100%);
}
&:hover{
color: white;
outline: none;
}
}
button:active{
outline: none;
box-shadow: inset 0px 7px 10px -10px;
background: linear-gradient(to bottom, rgba(76,76,76,1) 0%,rgba(0,0,0,1) 16%,rgba(17,17,17,1) 51%,rgba(28,28,28,1) 70%,rgba(28,28,28,1) 70%,rgba(44,44,44,1) 82%,rgba(43,43,43,1) 82%,rgba(56,56,56,1) 82%,rgba(44,44,44,1) 82%,rgba(66,66,66,1) 84%,rgba(84,84,84,1) 91%,rgba(109,109,109,1) 92%,rgba(102,102,102,1) 98%,rgba(28,28,28,1) 100%,rgba(19,19,19,1) 100%);
}
This code fixes your problem:
.button:active {
border-left-style: solid;
border-top-style: solid;
}
EDIT: or please check working codepen
The border you have on the button is the default border. Hou only adjusted the width and the color, not the style.
Therefore it's common practise to define a button like so:
border: 1.5px solid #fcbd3f;
Where solid is the style of the border.
I would like to make an HTML widget like this one:
https://jsfiddle.net/api/mdn/
.simple {
box-shadow: 5px 5px 5px rgba(0,0,0,0.7);
}
But I would like it to be pressable so that it flattens for 1 second and redirects to a different URL.
Edit:
I tried the following:
button {
width: 150px;
font-size: 1.1rem;
line-height: 2;
border-radius: 10px;
border: none;
background-image: linear-gradient(to bottom right, #777, #ddd);
box-shadow: 5px 5px 5px rgba(0,0,0,0.7);
}
button:focus, button:hover {
background-image: linear-gradient(to bottom right, #888, #eee);
}
button:active {
box-shadow: inset 2px 2px 1px black,
inset 2px 3px 5px rgba(0,0,0,0.3),
inset -2px -3px 5px rgba(255,255,255,0.5);
}
<button>Press me!</button>
https://jsfiddle.net/z7a0v8uv/
But I don't know how to translate the content of the button to make it look like it's being pressed down.
I found an answer here:
https://www.w3schools.com/howto/howto_css_animate_buttons.asp
I was looking for:
translateX(...) translateY(...)
As we can see in this working example:
https://jsfiddle.net/z7a0v8uv/1/
Now I just need to integrate this with the right style.
Edit:
Here is the complete CSS code:
button {
width: 100%;
border: none;
box-shadow: 5px 5px 5px rgba(0,0,0,0.7);
}
button:focus, button:hover {
background-image: linear-gradient(to bottom right, #888, #eee);
}
button:active {
box-shadow: 2px 2px 2px rgba(0,0,0,0.7);
transform: translateY(3px) translateX(3px);
}
I am trying to stylise a menu using CSS and I am having an issue with the text-shadow effect clipping inside the dropdown. The text itself seems to be clipping inside the select borders, which is surprising because I would have thought that it would be allowed to spread into the padded area.
html,
body {
font-family: Calibri;
margin: 0px;
width: 100%;
height: 100%;
text-align: center;
overflow: hidden;
cursor: default;
}
#dropdown_user_select{
position: absolute;
left: 25px;
top: 25px;
}
select {
background: none;
border: 1px solid;
border-radius: 2px;
box-shadow: 0px 0px 8px 0px #555, 0px 0px 25px 0px #555 inset;
text-shadow: 0px 0px 10px #555;
text-align: center;
transition: 0.4s all ease-out;
font-size: 25px;
padding: 10px 10px 10px 30px;
cursor: auto;
-webkit-appearance: none;
background: #DDD;
overflow: visible;
}
.cutoff {
overflow: visible;
}
#arrow_down {
/* a customised arrow on the left of the dropdown */
border-width: 15px 10px 0px 10px;
border-color: #000 transparent transparent transparent;
position: absolute;
left: 30px;
top: 45px;
}
<div class="cutoff">
<select id="dropdown_user_select">
<option value="ADMIN">ADMIN</option>
<option value="username">username</option>
</select>
</div>
<div id="arrow_down" class="arrow_pointer"></div>
as you can see, I have tried to use a div with the overflow: visible to fix this but it has not worked.
EDIT
By clipping, I mean the text-shadow is cut off inside of the tag. Here is an example that shows this better than the above:
html,
body {
font-family: Calibri;
margin: 0px;
width: 100%;
height: 100%;
text-align: center;
overflow: hidden;
}
#dropdown_user_select{
position: absolute;
left: 25px;
top: 25px;
}
select {
border: 1px solid;
border-radius: 2px;
text-shadow: 0px 0px 10px #F00;
font-size: 25px;
padding: 10px 10px 10px 30px;
-webkit-appearance: none;
background: #FFF;
overflow: visible;
}
<select id="dropdown_user_select">
<option value="ADMIN">ADMIN</option>
<option value="username">username</option>
</select>
The issue is probably that the <option> tag cannot have a padding itself, and the one set on the select actually pushes the left edge of the options, cutting off the shadow.
By using some trickery it seems to work on Chrome, it's not tested on other browsers although I assume it's fine.
The text-indent fixes the left shadow, while the line-height fixes the vertical shadows.
select {
border: 1px solid;
border-radius: 2px;
text-shadow: 0px 0px 20px #F00; /* increased to test vertical cut */
text-indent: 20px; /* fix the left shadow */
line-height: 40px; /* fix the top/bottom shadows */
font-size: 25px;
padding: 10px 10px 10px 0; /* removed left padding to compensate with indent */
-webkit-appearance: none;
background: #FFF;
overflow: visible;
}
<select id="dropdown_user_select">
<option value="ADMIN">ADMIN</option>
<option value="username">username</option>
</select>
It is hard to figure out what exactly you're trying to accomplish, but if I read correctly, the text inside is clipping outside of the borders for you. Also, I wasn't sure what you meant by the shadows... here's a JSfiddle:
html, body {
font-family: Calibri;
margin: 0px;
width: 100%;
height: 100%;
text-align: center;
overflow: hidden;
cursor: default;
}
#dropdown_user_select{
position: absolute;
left: 25px;
top: 25px;
}
select {
background: none;
border: 1px solid;
border-radius: 2px;
box-shadow: 0px 0px 8px 0px #555, 0px 0px 25px 0px #555;
text-shadow: 0px 0px 10px #555;
text-align: center;
transition: 0.4s all ease-out;
font-size: 25px;
padding: 10px 15px 10px 25px;
cursor: auto;
-webkit-appearance: none;
background: #DDD;
overflow: visible;
}
.cutoff {
overflow: hidden;
}
#arrow_down {
/* a customised arrow on the left of the dropdown */
border-width: 15px 10px 0px 10px;
border-color: #000 transparent transparent transparent;
position: absolute;
left: 30px;
top: 45px;
}
<div class="cutoff">
<select id="dropdown_user_select">
<option value="ADMIN">ADMIN</option>
<option value="username">username</option>
</select>
</div>
<div id="arrow_down" class="arrow_pointer"></div>
I edited the overflow value in .cutoff and took away inset from your box shadow in select. I also edited your padding values to accommodate for the width of the down arrow. Not sure if that was what was happening, but I hope I helped.
If it's not what happened, please explain to me what did happen so I can try to help.
I am trying to create a webpage like this (just the screenshot part). I tried to follow that tutorial, plus other on the internet but they don't seem to work. This is my css code:
/* CloudBase 2.0 overrides for Gantry Framework */
/* Basic styles */
body {color: #333;}
background:url(../images/St%20Pauls.jpg);
#rt-header, #rt-bottom {color: #333333;}
.rt-container {background: #fff;}
.rt-article a{text-decoration: underline;}
a:hover {color: #000; text-decoration: none;}
#rt-footer, #rt-copyright, #rt-copyright a {color: #333333;}
#rt-sidebar-a {background-color: transparent;}
#rt-sidebar-b {background-color: transparent;}
#rt-sidebar-c {background-color: transparent;}
#gantry-viewswitcher {margin: 0 auto 1em;position: relative;}
#rt-accessibility .button{
padding: 0px;
}
#rt-accessibility .button, .rt-joomla .icon {
background-image: url(../images/typography.png);
}
/* Layers structure */
#page-wraper{
width: 998px;
padding: 0px 37px;
margin: 20px auto 0px auto;
background: url(../images/background/shadow.png) 50% 0px no-repeat;
}
#in-page-wraper{
background: url(../images/background/bottom-shadow.png) center bottom no-repeat;
padding-bottom: 51px;
}
#in-page-wraper-2{
background: url(../images/background/content-background.png);
border: 1px solid #fff;
padding-top: 25px;
padding-bottom: 25px;
min-height: 500px;
}
.rt-container{
background: none;
}
#rt-mainbody{
background: #fff;
margin: 0px;
-moz-box-shadow: 2px 2px 9px rgba(0,0,0,0.1), -2px -2px 9px rgba(0,0,0,0.1);
-webkit-box-shadow: 2px 2px 9px rgba(0,0,0,0.1), -2px -2px 9px rgba(0,0,0,0.1);
box-shadow: 2px 2px 9px rgba(0,0,0,0.1), -2px -2px 9px rgba(0,0,0,0.1);
padding: 6px;
overflow: hidden;
}
#rt-mainbody .component-content{
border: 1px solid #dcdcdc;
padding: 15px;
overflow: hidden;
}
The
background:url(../images/St%20Pauls.jpg);
part doesn't seem to work for some reason. Apologies if this is a basic question.
Thanks!!
The background attribute doesn't seem to be contained by any CSS element. You need to insert it into the appropriate CSS selector element in order for it to be displayed. At the moment the link is just hanging out, not being applied to any part of the document.
First of all, you should check path to image. Open a browser and enter url as:
http://your_domain/../images/St Pauls.jpg
if all right you must see the image.
Secondly, you should use quotes for set path to images. It means that you must replace to
background: url('../images/St Pauls.jpg');
Third, better use name of file that not includes the spaces.
Finally, your CSS is not valid. It must be fixed
/* CloudBase 2.0 overrides for Gantry Framework */
/* Basic styles */
body {
color: #333;
background: url('../images/StPauls.jpg');
position: fixed;
}
#rt-header,
#rt-bottom {color: #333333;}
.rt-container {background: #fff;}
.rt-article a {text-decoration: underline;}
a:hover {color: #000; text-decoration: none;}
#rt-footer,
#rt-copyright,
#rt-copyright a {color: #333333;}
#rt-sidebar-a {background-color: transparent;}
#rt-sidebar-b {background-color: transparent;}
#rt-sidebar-c {background-color: transparent;}
#gantry-viewswitcher {margin: 0 auto 1em;position: relative;}
#rt-accessibility .button{ padding: 0px; }
#rt-accessibility .button,
.rt-joomla .icon {
background-image: url('../images/typography.png');
}
/* Layers structure */
#page-wraper{
width: 998px;
padding: 0px 37px;
margin: 20px auto 0px auto;
background: url('../images/background/shadow.png') 50% 0px no-repeat;
}
#in-page-wraper{
background: url('../images/background/bottom-shadow.png') center bottom no-repeat;
padding-bottom: 51px;
}
#in-page-wraper-2{
background: url('../images/background/content-background.png');
border: 1px solid #fff;
padding-top: 25px;
padding-bottom: 25px;
min-height: 500px;
}
.rt-container{
background: none;
}
#rt-mainbody{
background: #fff;
margin: 0px;
-moz-box-shadow: 2px 2px 9px rgba(0,0,0,0.1), -2px -2px 9px rgba(0,0,0,0.1);
-webkit-box-shadow: 2px 2px 9px rgba(0,0,0,0.1), -2px -2px 9px rgba(0,0,0,0.1);
box-shadow: 2px 2px 9px rgba(0,0,0,0.1), -2px -2px 9px rgba(0,0,0,0.1);
padding: 6px;
overflow: hidden;
}
#rt-mainbody .component-content{
border: 1px solid #dcdcdc;
padding: 15px;
overflow: hidden;
}
If you still not see image you can try use as background: url('/images/StPauls.jpg'); or background: url('images/StPauls.jpg');
You will need to make sure your background declaration is being applied to the body element:
body {
color: #333;
background:url(../images/St%20Pauls.jpg);
}
you will also need to check that the image you specified is correctly located in the images directory
I am trying to add a background image to a button (or link with the same class) which already has a background color.
Here is the jsfiddle: http://jsfiddle.net/BNvke/
The button looks great by itself, but I am trying to make it so that if I add a certain class, the padding will be adjusted and a background image will be displayed, however the image does not show. Here is the CSS/HTML:
.button {
padding: 10px;
margin-right: 8px;
margin-bottom: 10px;
font-family: Arial, Tahoma, Verdana, FreeSans, sans-serif;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
display: inline-block;
white-space: nowrap;
line-height: 1em;
position: relative;
outline: none;
overflow: visible;
cursor: pointer;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
box-shadow: 1px 1px 2px 0 #CCCCCC;
-moz-box-shadow: 1px 1px 2px 0 #CCCCCC;
-webkit-box-shadow: 1px 1px 2px 0 #CCCCCC;
}
.button_blue {
border: 1px solid #305875;
color: #FBFBFB;
background-color: #3D6E97;
}
.button_blue:hover {
color: #FBFBFB;
opacity: 0.9;
filter: alpha(opacity=90);
}
.button_about {
background-image: url(http://i47.tinypic.com/2ni0ahd.png) 3px 5px no-repeat;
padding-left: 35px;
padding-right: 15px;
}
<p><a class="button button_blue">Without Background</a></p>
<p><a class="button button_blue button_about">With Background</a></p>
How can I get that background image to show?
see http://jsfiddle.net/BNvke/1/
just change
background-image url(http://i47.tinypic.com/2ni0ahd.png) 3px 5px no-repeat;
with
background: url(http://i47.tinypic.com/2ni0ahd.png) 3px 5px no-repeat;
and move up the last rule so the rule about background-color defined for .button_blue can be applied on cascade
.button {
background: url(http://i47.tinypic.com/2ni0ahd.png);
background-repeat: 3px 5px no-repeat;
}