There is a button. Inside the button text. How to move the text when you click on an 1 px down, not moving with the button itself, only the text inside?
<span class="button-wrapper">
<a href="#" class="button">
button text
</a>
</span>
1.button-wrapper - Serves as the gradient border
2.element have 1px margin + background-gradient
If I have orders from the top padding, clicking, button increases in size, but I just need to move text within a tag and, without moving a button, how?
It might be worth using the right markup to properly achieve your desired effect.
<button class="button">
<span href="#" class="innerButton">
button text
</span>
</button>
Then you can use this CSS to move the span 1px down on click.
.button span
{
position: relative;
}
/*while pressing*/
.button span:active
{
top: 1px;
}
http://jsfiddle.net/UuyFe/
Or, alternatively, for the text in a single input button element
<input id="submit" type="submit" value="Submit" />
this CSS may be useful:
#submit
{
padding-top: 4px;
}
#submit:active
{
padding-top: 6px;
}
I had a similar problem and fixed it as follows, though I don't particularly understand why the float is necessary. Any comments on that would be greatly appreciated.
I'm using padding to make the text move, by adding 1px top + left and subtracting 1px right + bottom. But for some reason that I don't understand, this alone pushes the sibling boxes down 1px. We don't want the buttons themselves to move, though.
HTML:
<p>
<span class="button">third</span>
<span class="button">fourth</span>
</p>
<p>
<input type="button" class="button button2" value="fifth" />
<input type="button" class="button button2" value="sixth" />
</p>
CSS:
.button {
outline: none;
background-color: blanchedalmond;
border: 1px solid maroon;
padding: 3px 10px 4px 10px;
box-sizing: border-box;
display: inline-block;
position: relative;
line-height: 20px;
margin: 0;
}
span.button {
display: inline-block;
text-indent: -9999px;
width: 20px;
height: 20px;
}
p {
background-color: magenta;
overflow: auto;
}
.button2 {
float: left;
margin-right: 4px;
}
.button:active {
background-color: red;
border: 1px solid brown;
padding: 4px 9px 3px 11px;
margin-top: 0px;
}
Fiddle where "fifth" and "sixth" behave like we want them to because we added float.
Related
I'm looking to find out how to add another box inside my box which would be faded to act as a title bar for that specific box (If that makes sense)!
So basically, in the SOCIALBOX I'm looking to get a sub-faded bar at the top inside which would act as a title bar.
After a few comments of people saying they're not sure what I mean, I created a quick image in photoshop to act as some reference point.
Code Snippet:
body {
background: url("../images/backgroundimage.jpg") repeat 0 0;
}
/* CSS MENU BAR CODE GOES HERE */
#menubar {
width: 98.5%;
height: 40px;
background-color: #000000;
position: fixed;
border: 2px solid #ffffff;
}
.inside_text {
color: #FFFFFF;
float: right;
margin: 11px 7px 0 0;
}
.inside_text2 {
color: #FFFFFF;
float: left;
margin: 11px 0 0 7px;
}
/* CSS SOCIALBOX (RIGHT) GOES HERE */
#socialbox {
width: 40%;
height: 40%;
position: relative;
float: right;
margin: 0 8px 0 0;
background-color: #000000;
border: 2px solid #126b72;
}
<div id="menubar">
<div class="inside_text">
PLACEHOLDER TEXT
</div>
<div class="inside_text2">
PLACEHOLDER TEXT
</div>
</div>
<br />
<br />
<br />
<div id="socialbox">
</div>
So you are asking for a faded line within SOCIALBOX div, to serve as underline for a title?
If thats correct create another class
.title-bar
{
border-bottom:3px;
solid black;
opacity:0.3;
}
position with margin-left & margin-top values inside that class based on where you want it within SOCIALBOX.
for example:
.title-bar
{
border-bottom:3px;
solid black;
opacity:0.3;
margin-left:50px;
margin-top:30px;
float:left;
}
create a:
<div class="title-bar"></div>
and place that inside
<div id="socialbox"></div>
BTW make it a habit to use float:left when positioning divs with CSS, try to avoid position:absolute or fixed, unless absolutely necessary. It just comes out cleaner this way.
I want to have border to my label text and its associated textbox. I have used border-bottom property but because my label is padded to left its border is not right below it.
html
<div>
<span class="elements">
<label class="field" for="Title">Title</label>
<input name="Title" readonly="readonly" type="text" value="Mr">
</span>
</div>
css
.elements {
padding: 10px;
border-bottom: solid;
border-bottom-color: #1f6a9a;
}
.field {
font-size: 15px;
color: #b6d6ed;
padding-left: 44px;
}
label {
display: inline-block;
width: 80px;
}
input {
background-color: transparent;
border: 0 solid;
height: 25px;
width: 300px;
color: #b6d6ed;
}
jsfiddle : http://jsfiddle.net/2HARy/
I want to have border start from "Title" text only
Remove padding-left: 44px from the .field element and use a margin on the parent element instead. In doing so, the border will start at "title".
Updated Example
.elements {
padding: 10px;
margin-left: 44px;
border-bottom: solid;
border-bottom-color: #1f6a9a;
}
.field {
font-size: 15px;
color: #b6d6ed;
}
Additionally, if you want the border to start directly at the text, remove the padding-left on the .elements element. (example).
Since you have padding-left:44px there is no way to have the border start from the "Title" text. What you must do is remove that property from .elements, wrap .elements in a div, and apply the padding-left property to that div.
Here is a jsfiddle http://jsfiddle.net/3TChG/
I am trying to get the following result, but cannot get the css correct - I keep getting either a span on a new line, or all of the span's inline.
I've tried messing with display, clear, float, etc. and just can't seem to get this to line up?
I can use table to do this, and it works fine...but think there must be a css way to acheive the same?
<div>
<span class="button">
<button type="button">
CLICK!</button>
</span>
<span class="field">
<span>
Field 1
</span>
<span>
Field 2
</span>
</span>
</div>
.button
{
margin: 1em 10px 0px 0px;
width: 250px;
text-align: right;
display: inline-block;
}
.field
{
margin: 0.5em 0px 0px;
color: #002c5a;
}
Your new css: Change display:inline-block to float:left; in both classes (button & field) and add display:block; to .field span {}.
.button
{
margin: 1em 10px 0px 0px;
width: 250px;
text-align: right;
float:left;
}
.field
{
float:left;
margin: 0.5em 0px 0px;
color: #002c5a;
}
.field span { display:block;}
DEMO
Demo 2 is with more css that looks like you sample!
DEMO 2
Try:
.button,.field{display:table-cell;vertical-align:middle;padding:5px;border:1px solid #ccc;width:50%;}
.button{text-align:right;}
.field{text-align:left;color: #002c5a;}
div{display:table;margin:0 auto;width:100%;}
.field span{display:block;}
DEMO here.
it's possible to make it like this when you onfocus (onclick) on the input text. Any help would be appreciated.
You can make use of outline and :focus, these are compatible with major browsers.
HTML
<input type="text" class="inp" />
<br>
<input type="text" class="inp" />
CSS
.inp{
border:solid 2px gray;
margin: 20px 5px;
outline:solid 10px silver;
}
.inp:focus{
outline:solid 10px red;
}
Preview on JSFiddle
You can do it like this :
input:focus
{
background-color:blue;//*
}
*this is just a example to change the background color.Do any thing that u desire here
Take look at complete example here.
You can wrap the input with an anchor tag, and set it to change background-color onfocus:
<a class='focused'><input /></a>
with CSS:
.focused:hover{
background-color:blue;
}
or, if you want it to change when the input is active, you need to use javascript/jQuery.
I think you would have to wrap each input in a div and give that div a background color when it has focus using JavaScript. Here's a version in jQuery...
$(document).ready(function() {
$('input').on('focus', function() {
$(this).parent().css('background-color', 'blue');
});
});
I think this CSS trick can be used rarely in real cases, but it is funny, that we can make this effect with box-shadows.
http://jsfiddle.net/XSpwg/
HTML:
<div>
<form>
<input></input>
<input></input>
<input></input>
</form>
</div>
CSS:
div {
background-color: lightgrey;
width: 80%;
max-width: 400px;
overflow: hidden;
padding: 5px;
}
input {
margin: 2em 0.5em;
display: block;
border: solid 2px lightblue;
outline: none;
height: 16px;
line-height: 16px;
font-size: 12px;
}
input:focus {
box-shadow: 180px 227px 0 200px lightgrey,
180px 195px 0 200px blue;
}
Use pseudo-class selector for various effects.
There are two possible methods using CSS
Method 1 --> if you need both hover and on focus effect then use border styling for the <input> element
here is a typical HTML and CSS for method 1, --> Jsfiddle view
HTML
<form class="form-style">
<input class="input-style" type="text" name="some-name">
<input class="input-style" type="text" name="some-name">
</form>
CSS
.form-style
{
width: 250px;
margin:auto;
background-color: #d6d6d6;
display:block;
}
.input-style
{
width:200px;
margin:auto;
padding-left: 0px;
padding-right: 0px;
line-height: 2;
border-width: 20px 25px;
border-collapse: separate;
border-style: solid;
border-color: #d6d6d6;
display: block;
}
input.input-style:focus, input.input-style:hover
{
border-color: #3399FF;
}
Method 2 -> if you need just a hover effect then enclose the <input> element in a <div> and add :hover effect to it, or you can use the method 1 :hover and remove the :focus selector
here is a typical HTML and CSS for method 2, --> Jsfiddle view
HTML
<form class="form-style">
<div class="input-style">
<input type="text" name="some-name">
</div>
<div class="input-style">
<input type="text" name="some-name">
</div>
</form>
CSS
.form-style
{
width:250px;
margin:auto;
display:block;
}
.input-style
{
width: 200px;
background-color: #d6d6d6;
padding:20px 25px 20px 25px;
display: block;
}
.input-style input
{
width:inherit;
line-height: 2;
display: block;
}
.input-style:hover
{
background-color: #3399FF;
}
My advice -> just use on focus effect, because on hover will highlight the <input> on which the mouse is over even if you you are typing (on focus) in another <input>
I have an input box
<span class="arrowDate"><input type="text" value="<?php echo $inputValue; ?>" id="<?php echo $id; ?>" class="datePickBox" /></span>
What I want to achieve is to add via css and image with and arrow in the right hand corner of the input box. If I change properties to the image, the properties of the input box should remain the same. Basically the image should be a type of overlay for the input box, but do not know how to do this.
.datePickBox{
font-size: 0.9em;
border: 1px solid #DEDEDE;
width: 270px;
position:relative;
right:0px !important;
padding-right:20px;
}
.arrowDate{ background:url('../images/arrow.png') no-repeat right center; border:1px solid #DEDEDE; }
Give your <input> a transparent background so the background of the <span> can shine thru and remove the border, because the border comes from the <span> in your case;
.datePickBox {
background: none;
border: none;
}
But your text will be over the background image, if long enough, so you can additionaly add a right padding as large as the image is wide.
.datePickBox {
background: none;
border: none;
padding-right: 20px; /* bg image width */
}
Given the mark-up:
<span><input type="text" id="textInput" name="textInput" />→</span>
I used the CSS:
span {
display: block;
width: 150px;
height: 30px;
position: relative;
background-color: #ffa;
text-align: right;
overflow: hidden;
border-radius: 1em;
border: 1px solid #ccc;
line-height: 30px;
padding: 0 0.5em 0 0;
}
span > input {
position: absolute;
top: 0;
left: 0;
right: 2em;
bottom: 0;
background-color: transparent;
border-radius: 1em 0 0 1em;
border-width: 0;
border-right: none;
outline: none;
}
To give the following JS Fiddle demo.
It's worth noting that I explicitly chose to place the arrow alongside the input, instead of 'overlaying' it above the input. It's also possible to amend my answer from the a similar question to create a comparable layout with a submit button alongside the input.
Can't get the image to display within the input box, with overlay I mean floating above the input box
you won't be able to get it floating above the text with background-image.
One way to do this would be to place the image next to the input field, and using relative positioning to move it above it.
CSS:
.boximage { position: relative; left: -40px; z-index: 2 }
HTML:
<input type='text'><img class='boximage' src='image.gif'>
better use this
<span><input type='text' /><img src='datepicker.jpg' /></span>
change the css to meet your overlay.. remove the right border of the text box