how to set image into div - html

I am trying to fit a image into div but something going wrong, actualy i just want when i set a image into div it should not affect the div property.
i am trying like this:
#image_try {
background-color: white;
-webkit-box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 0px 1px 6px rgba(23, 69, 88, .5);
-webkit-border-radius: 12px;
-moz-border-radius: 7px;
border-radius: 7px;
background: -webkit-gradient(linear, left top, left bottom,
color-stop(0%, white), color-stop(15%, white), color-stop(100%, #D7E9F5));
background: -moz-linear-gradient(top, white 0%, white 55%, #D5E4F3 130%);
float: right;
border: 2px;
color: #FF0000;
overflow: hidden;
width: 164px;
display: table;
margin: 0 auto;
padding: 78px 31px 7px 233px;
background: #FFFFFF;
height: 79px;
margin-top: -174px;
margin-right: 25px;
background-image:url(images/weather.jpg) no-repeat;
}
updates:
Actualy when i did not set image in background then div looks like good but when i am setting image its height and width being affected
any idea... answer will be fully appreciate...thank you

I can see few dupe in your css like for background, you using color twice also you are setting it to gradient for Chrome and Firefox. You are repeating margin too. As far as i can under stand your problem was with padding. I removed that only. Kindly check the css and provide screenshot if possible.
#image_try {
-webkit-box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 0px 1px 6px rgba(23, 69, 88, .5);
-webkit-border-radius: 12px;
-moz-border-radius: 7px;
border-radius: 7px;
border: 2px;
color: #FF0000;
width: 164px;
height: 79px;
background-image:url(images/weather.jpg) no-repeat;
}
Try above edited answer

Related

how to put image on button? (css)

I have problem with my css code, I'm trying to put an image in a button, but the image goes down and not in the rigth side as I want.
What I need is that my image calendar to be in the same level as the text, I need this to be done in only one div, I know how to do it with two separate divs, but this is not the case, pelase help.
here is my code:
#import url("http://fonts.googleapis.com/css?family=Maven+Pro");
.date_Button {
height: 48px;
width: 150px;
font: bold 16px/48px arial;
margin: 20px 20px 20px 20px;
position: relative;
}
/* ===============================
========= GREY STYLE ==========
===============================
================================================== */
.grey-button-date:first-child {
/* styling for the left part */
padding-top: 10px;
width: 100px;
height:40px;
text-align: center;
/* border radius */
-webkit-border-radius: 4px 4px 4px 4px;
-moz-border-radius: 4px 4px 4px 4px;
border-radius: 4px 4px 4px 4px;
/* backgorund */
background: -webkit-gradient(linear, left top, left bottom, from(#fbfbfb), to(#c6c6c6));
background: -moz-linear-gradient(#fbfbfb, #c6c6c6);
background-color: #ccc;
/* shadows and highlights */
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(255, 255, 255, 0.8) inset;
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(255, 255, 255, 0.8) inset;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(255, 255, 255, 0.8) inset;
}
.date_Button:hover .grey-button-date:first-child {
background: -webkit-gradient(linear, left top, left bottom, from(#fdfdfd), to(#d5d5d5));
background: -moz-linear-gradient(#fdfdfd, #d5d5d5);
background-color: #ddd;
}
.date_Button:active .grey-button-date:first-child {
background: -webkit-gradient(linear, left top, left bottom, from(#d5d5d5), to(#fafafa));
background: -moz-linear-gradient(#d5d5d5, #fafafa);
background-color: #fbfbfb;
}
.date_Button:hover .grey-button-date {
background: -webkit-gradient(linear, left top, left bottom, from(#fdfdfd), to(#d5d5d5));
background: -moz-linear-gradient(#fdfdfd, #d5d5d5);
background-color: #ddd;
}
.date_Button:active .grey-button-date {
background: -webkit-gradient(linear, left top, left bottom, from(#d5d5d5), to(#fafafa));
background: -moz-linear-gradient(#d5d5d5, #fafafa);
background-color: #fbfbfb;
}
.grey-button-date a {
/* link styling */
color: #333;
font: bold 16px/32px arial, helvetica, sans-serif;
text-decoration: none;
text-shadow: 0 1px 0 #fff;
}
<h3>Date</h3>
<div class="date_Button">
<div class="grey-button-date">
09/02/15<img width="50px" src="calendar-03.svg">
</div>
</div>
You've defined a width and height for your grey-button-date. The image can't fit inside. Try removing your height:
.grey-button-date:first-child {
/* styling for the left part */
padding-top: 10px;
width: 100px;
text-align: center;
See this JSFiddle.
You also might want to look into putting the entire grey-button-date inside your <a> tag.

Move Menu Navigation (Margin?)

I need to move this navigation menu above the content box and below the logo. In other words, the order should be: (1) logo, (2) menu, and (3) content box.
I tried various margin adjustments to the CSS for #navigation to no avail.
How do I do this?
URL: http://ec2-174-129-169-80.compute-1.amazonaws.com/
See screenshot:
You could add top: -57px; to your #navigation CSS like so:
#navigation {
position: relative;
top: -57px;
clear: both;
margin-bottom: 3em;
display: none;
font: 14px/14px sans-serif;
border: 1px solid #D9D9D9;
background: white;
background: -webkit-gradient(linear, left top, left bottom, from(white), to(whiteSmoke));
background: -webkit-linear-gradient(white, whiteSmoke);
background: -moz-linear-gradient(center top, white 0%, whiteSmoke 100%);
background: -moz-gradient(center top, white 0%, whiteSmoke 100%);
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.03);
-webkit-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.03);
-moz-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.03);
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
Make a jsFiddle or post your code please. Without seeing code, first thoughts are that you put the #navigation in the content area. If that's the case, then:
#navigation { margin-top: -50px; }
If #navigation is absolutely positioned:
#navigation { top: -50px; }

Keeping inline text in place

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

How to create a CSS border surrounding an input box?

I cannot seem to Google my way out of this one. I am trying to re-create the input box shown below. I would like to create a subtle transparent border outside the input box (will be a bit less transparent, kind of hard to see in mock-up.)
It seems to be making the border inside of the text box, not outside it. Also it is making a sharp highlight on the bottom of the border (possibly the bottom of the input box itself.)
Mock-up Images
My CSS for the input box
#merchantForm>form>input.inputValue {
border-radius: 3px;
height: 30px; width: 350px;
margin-top: 5px;
font-family: Helvetica,sans-serif; font-weight: bold; font-size: 19px; color: #333;
-moz-box-shadow: 0px 1px 0px #f2f2f2;-webkit-box-shadow: 0px 1px 0px #f2f2f2;
border-style: solid;
border-width: 5px;
border-color: rgba(0,0,0,0.3);
}
Any ideas? I'm kind of new to CSS, so any suggestions to improve my CSS is welcomed as well.
The background of an element extends underneath the border by default. To change this behaviour use the following:
-webkit-background-clip: content-box;
-moz-background-clip: content-box;
background-clip: content-box;
Another, simpler option is to use the spread property of CSS box-shadows:
-webkit-box-shadow: 0 0 0 10px hsla(0, 0%, 0%, 0.5);
-moz-box-shadow: 0 0 0 10px hsla(0, 0%, 0%, 0.5);
box-shadow: 0 0 0 10px hsla(0, 0%, 0%, 0.5);
you could just add an input background-image: to your field in your css image sprite and call it a day and have consistency in all browsers.
This should do the trick. =) (Rough sample: http://d.pr/nDaN)
input.custom-input {
width: 250px;
font-size: 20px;
padding: 15px;
border: none;
border: 5px solid rgba(0,0,0,0.75);
border-radius: 5px;
box-shadow: inset 5px 5px 5px #CCC;
}

Button width in css3

I have a button and I want it to be a particular size
html
<a class="button icon Raise"
onclick="raiseButtonAction(realPlayer, gameState)" id="nupp1" href="#"><span>RAISE</span></a>
css
.button {
position: absolute;
border-top: 1px solid #96d1f8;
background: #65a9d7;
background: -webkit-gradient(linear, left top, left bottom, from(#3e779d),
to(#65a9d7) );
background: -moz-linear-gradient(top, #3e779d, #65a9d7);
padding: 5px 10px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: rgba(0, 0, 0, 1) 0 1px 0;
-moz-box-shadow: rgba(0, 0, 0, 1) 0 1px 0;
box-shadow: rgba(0, 0, 0, 1) 0 1px 0;
text-shadow: rgba(0, 0, 0, .4) 0 1px 0;
color: white;
font-size: 19px;
font-weight: bold;
font-family: Segoe;
text-decoration: none;
vertical-align: middle;
But if I put for example width:100px; it doesn't change in size.
Am I doing something wrong or you just can't change the size of a premade button?
Try this..
.button {
display:inline-block;
min-width: 50px;
width: 80px;
padding:5px 10px;
}
That style is on an a element, which is an inline and won't accept a width. You could change it to be inline-block or block and then you'll have control over the width.
You need to make your <a> into a block level element. Here's an example of it working.
I just added this to your CSS for .button:
display: block;
width: 200px;
text-align: center;
Missing
display: block;
Have to set display to block if you want to set a fixed width on an inline element