Css rounded image - css

I have an image with rounded corners(png transparent on the corners), about 150px wide, and 25px height, so i'm trying to use it, but it doesn't work for me:
<button><span>Click me</span></button>
And the css:
button{
border:0;
background:url(../images/button.png) no-repeat top left;
height:24px;
padding-left:10px;
}
And
button span{
display:block;
background:transparent url(../images/button.png) no-repeat top right;
height:24px;
padding-right:10px;
}
But it doesn't work correctly, the right corner isn't displayed correctly.Any help?
Best Regards,

Using Firebug (use it!) it is clear what is happening. Your right corner shows, but as the the button underneath it continues, you simply don´t see it.
You can solve that using two images, a small one (not so wide, minimum width the padding on the left side) for the left corner and a very wide one for the right corner. That way your buttons don´t overlap and you get the desired effect.

First things first: How is it displayed?
You're using the same background images for both left and right corner. Is that in order? (I realize that technically it could be) Also, you might want to try and switch the two (left/right), as span is not a block element, and that might be causing your problems (much in the same way that you can't, say, set a width to a span, unless you also set it to render as a block)

your span and button elements have the same height (which is smaller than image height by the way). Another observation: why do you need span element at all?
start with the simplest way to do something:
<button>Click me!</button>
button {
border: 1px solid #ff0;
padding: 10px;
display:block;
background:transparent url(../images/button.png) no-repeat top centre;
height:25px;
}
this should display your image. Use border property to debug CSS

Related

background "see" padding on select box

I have a form with a a select box that has a custom drop down arrow, put in place with the background property in my CSS. Right now it's positioned to the right, but that means it butts up right against the side of my box - is there some way I get get the arrow to "see" the padding to the right of it?
CSS:
select {
background: url(images/contact/downarrow.svg) no-repeat right #f3f3f3;
}
RESULT:
Or you can try to use a <img src="images/contact/downarrow.svg" />
with float: right;
And it will be nicely positioned to the right and will follow the Padding rules at your Tab area.
Good luck.
For others:
if you use something like
background: url(images/contact/downarrow.svg) no-repeat 250px #f3f3f3;
that's going to (sensibly) just stick it 250px over, and when you resize the window it'll eventually be covered over by the shrinking screen size. To prevent this, replace those pixel values with percentages. Eg:
background: url(images/contact/downarrow.svg) no-repeat 96% #f3f3f3;

Border interfere with absolute positioning

I am trying an animation in which you click the button, and it fill up with the color from bottom to top. When you click it, the element with position absolute changes and goes up the box.
Demo (after clicking the element, try resizing your window and see the problem)
Before animation the css is:
#boton_auto {border-bottom: 5px solid #2dbbdc;}
After animation (80px is the height of the box):
#boton_auto {border-bottom: 80px solid #2dbbdc;}
I know I could use top:0px; but I need the elements to be align baseline with other buttons. Am I clear?
Thanks for any help!
To start in your fiddle you are not calling properly the svg class (you are missing the dot. You wrote "svg" insteed of ".svg".
And I woudn't use border to achieve your efect. If you are looking for a full responsive image as the width 28% may indicate I would insteed use a full absolute container which will grow (vertically) on click:
.blue {
height:4px;
position:absolute;
bottom:0px;
width:100%;
background-color:#2dbbdc;
z-index:-1;
}
then you won't have problems with the span (the AUTO text), going to the top.
I've made this fiddle for you
If i understand the question correctly You could use position: relative; and then describe how far away from the bottom of the button you want. Ex:
*if you want 80 pixels you could just add them. Start + finish.
this is for the bottom (before animation)
# boton_auto {position:relative;
border-bottom: +85px solid #2dbbdc;}
this is for the top (for after animation)
# boton_auto {position:relative;
border-bottom: +5px solid. #2dbbdc;}

Changing background images

I am fairly new to code and taking baby steps with an issue I am having: swapping out background images. I made very slight adjustments to the three images that make up the background of the site. One was a main background image (in a bodywrap container) that loaded just fine. The next was a wrapper image with a repeat-y attribute that is no longer taking since the swap - the image shows up, but is just showing up as a single white line, while it is meant to 'fill' the rest of the page. Finally, the footer image is not showing up at all.
I thought that swapping out the current images with ones that were only slightly adjusted in photoshop (all I did was remove drop-shadows and red margins) would be an easy task - my mistake!
I tried adjusting the code and got nowhere, so I've copied the original code. I believe that the problem lies within my CSS:
#wrapper, footer, .pagetop, .copyright {
width:942px;
margin:0 auto;
padding:0px 37px 0px 37px;
overflow:hidden;
clear:both;
}
.bodywrap {
background: url(images/background.png) 49.9% 0% repeat-x;
width:1016px;
margin:auto;
overflow:hidden;
}
#wrapper {
background: url(images/wrapper.png) 49% repeat-y;
clear:both;
padding-bottom:25px;
min-height:225px;
}
.footer {
background: url(images/footer.png) no-repeat 51% 0%;
overflow:hidden;
min-height:107px;
font-size:1.2em;
padding-top:17px;
font-family: 'Francois One', sans-serif;
}
Thanks in advance for sharing your expertise!
First thing I see that your background instructions are not consistent. Your no-repeat is before and after your alignment values. I would suggest to try keeping it the same everywhere in your code. when your code gets heavy it can be confusing.
body {
background: #ffffff url("img_tree.png") no-repeat right top;
}
right means align the image on the x axe to the right and
top means align the image on the y axe to the top
Do you understand that your 49.9% values are telling the background image to start repeating at 49% to the left from the edge of the box you as it to be in.
Also your .bodywrap does not have a height. if you only see a small line, this is because your element is only taking up the space the content inside this element is taking. you might have a space or 1 line of code. hard to say without the HTML.
So you need to give the .bodywrap element a min-height or height equal to your image height. The image you provide AS background to an element, does not define that element's height. The <img> tag and an image background don't work the same. an <img> tag will determine its height on its own but you cannot repeat it like a background.
Here you can see more information on background here: http://www.w3schools.com/css/css_background.asp

Align text center(minus) 10px

I have a menu system which uses an image 170px wide by 1px tall (repeated indefinite) It has a 10px border on the left, but a 30px border on the right.
is there a way to center the text, but accounting for the extra 20px on the right side?
Fiddle SiteCode: http://jsfiddle.net/jgallaway81/AXVT5/1/
Relevant Code:
.menubuttonthin {margin-left:0px; margin-top:0px; margin-bottom:0px; width:170px; height:30px; display:block; line-height:30px; font-family:courier; font-size:small; color:#C8C8C8; text-decoration:none; font-weight:900; background-image: url(../_pic-lib/lcars-frame-button-thin.png); }
FCCorp.US Story
As you can see, I don't have the links div'd, because they are encapsulated by a div that created the menu area box. Also, I've tried margining and padding both sides, but all that does is increase the size of teh box, throwing off the background image so it doesn't match up to the background image of the site.
Place your text in a <div> and use the following style for it:
text-align:center;
margin-right:-20px;
For example, if you want to use inline style:
<div style="text-align:center; margin-right:-20px;">
</div>
If I'm understanding you're question, one approach would be to do something along these lines:
CSS;
foo {
width: 130px;
padding: 0 30px 0 10px;
text-align: center;
}
HTML:
<div class="foo">Whatevs</div>
That'll confine the contents of the div to just the non-border area.
Okay, one opinion... I'm a real idiot.
Answer:
It wasn't until madhushankarox mentioned text-indent that the answer came to me. Reduce the size of the link area to eliminate the difference between both sides as far as the text-centering was concerned, but then use padding to increase thesize to ensure the entire button image was displayed.
.menubuttonthin { padding-right:10px; width:160px; }
(only included the changes) width was shrunk from 170px to 160px, which created the centering; the padding increased teh size of the box, showing the last 10px of the background (button) image
Thanks for all the help!
Course, after I posted this, I realized that Ultranaut was right all along. Sorry about that. I checked your answer as the right one. Thanks.

How to add custom margins and control their shape using css?

I am trying to style h1 using following image...
Currently my code as following...
h1{
background:#add2cb;
padding:15px 20px;
color:#387475;
font-size:16px;
font-weight:bold;
}
But i want yours help to add left and right bottom curve using css. I have tried lots of ways, please help me to rewrite css code to achieve this. thanks.
You should totally check out Harry Roberts version, the beauty is you won't be requiring any additional elements to pull it off.
http://csswizardry.com/2011/02/css-powered-ribbons-the-clean-way/
This method will include a few images, however because they're only for the curled under parts there will be less weight to download and will degrade better.
You cannot add curves like that with CSS alone, those will have to be a single image. If the H1's are all going to be the same size, then you can have an image of the bottom of that and then add this line to your h1 CSS
background: url("path/to.image") bottom center no-repeat;
I'm not sure if it is possible to make it work with H1's that are different sizes unless you want to use <div>s instead.
With 1`s you can do this:
HTML:
<div class="heading"><span>Text Goes Here</span><div>
CSS:
.heading { background: url("left-curve-image.jpg") left center no-repeat #add2cb;
padding:15px 20px;
color:#387475;
font-size:16px;
font-weight:bold; }
.heading span { background: url("right-curve-image.jpg") right center no-repeat #add2cb; }
Just please note that you will need snips of the left and right side of the curve from top to bottom

Resources