Reduce spacing between input text and bottom border - html

I'd like to reduce the space between the bottom border of the input text field and the text so that they're closer together.
#a {
padding: 1px 3px;
background: transparent;
border: 0;
outline: 0;
border-bottom: 0.8px solid #D3D3D3;
width: 300px;
}
<div style="text-align: center;"><input type="text" id="a" style="font-family: open-sans, sans-serif; font-style: normal; font-weight: 300; color: black; font-size: 16px; text-align: left;"></div>

Give #a a height of 10px (less than size of the font)
(Edit - 13 px would be best, consider visibility of characters like small case q,p,y.. etc)
Fiddle - https://jsfiddle.net/xpvt214o/735385/
#a
{
padding: 1px 3px;
background: transparent;
border: 0;
outline: 0;
border-bottom: 2px solid #D3D3D3;
width: 300px;
height: 10px;
}

If you change your padding to:
padding: 1px 3px 0px;
It'll save you a pixel of space at least. The first value is the top and bottom border by default, and the 2nd is right and left. A third value when specified refers to the bottom specifically, and a 4th refers to left specifically.
Alternatively, you could use a 1-pixel image with a repeat as a background instead of a border and position it 1px from the bottom so save another pixel or two, but I think sticking with a simple border is probably cleaner.
If you want to go the image route, here's how to do it:
create a 1px x 1px image in the color you want, and do something like this:
border-bottom: 0px;
background-image: url('insert-imageURL');
background-repeat: repeat-x;
background-position-y: -2px;
The repeat will turn it into a line, and the position will bump it up from the bottom edge of your field by however many pixels you like. Put in your image link inside the URL field.
You'll have full control over exactly where the line goes in relation to the field.

Related

How defining output length & adding 2 background to button in CSS

I've been working on my first website and run out with some questions I couldn't find any solution online. Hopefully someone could guide me what are the keywords I should lookup.
1) How can I define the length of the border of the output (without wrapping it with div)? I would like to set a constant width of the output value (that would be empty if there is no value), but I can't seem to find how to do so. In CSS, border-bottom-width actually set the height.
output {
border-bottom: 1px solid #000000;
margin: 3em 0% 3em 0%;
color: aquamarine;
background: transparent;
text-align: center;
}
2) How can I set to a floating button a gradient in the back background and an image in the front? For some reason, it seems that I can use only one of them.
<button onclick="calc(this)" class="calc" src="/img/calculator.svg"></button>
.
.calc {
width: 4em;
height: 4em;
padding: 0.3em;
position: fixed;
bottom: 3em;
right: 3em;
background-image: radial-gradient(#aac0e8, #b9cde5, #dce6f2) url('/img/calculator.svg'); //the picture isn't shown
border-radius: 50px;
box-shadow: 2px 2px 3px #999;
outline: none;
border: #17375e;
}

Form highlight and outline size

So I have a field that is supposed to have a black outline. Like this
Where the 237 is. But here's what I have
.r{
height: 40px;
font-size: 30px;
width: 100px;
font-family: 'proxima_novalight';
outline: none;
background: none;
outline: 3px solid black;
}
For some reason when I select the field it gets smaller. And on initial load, there's kind of like an outline around it. A grayish one. You could call it a shadow Here's a demo. Ideas?
Use border instead of outline to remove the "shadow":
.r{
height: 40px;
font-size: 30px;
width: 100px;
font-family: 'proxima_novalight';
outline: none;
background: none;
border: 3px solid black;
}
JSBin: http://jsbin.com/cuwurowu/2/edit
The “shadow” is the default border of the input element. To remove it, add
.r { border: none }
(but note that this affects the totals dimensions of the element, which may matter in pixel-exact layout).
The shrinking effect in Chrome (does not seem to happen in Firefox or IE) is apparently caused by a browser default style sheet that sets outline-offset: -2px on the element when it is focused. The outline-offset sets the distance between an outline and the outer edfes of the element, so a negative value shrinks the outline. To fix this, add
.r { outline-offset: 0 }

Style input field to look like a trapezium

I'm trying to create a custom styled text field for a client.
They want a trapezium shaped input field.
This is what I've done till now:
HTML
<input type="text">
CSS
input{
background: #ccc;
color: #000;
border-bottom: 50px solid #ccc;
padding-top:5px;
border-left: 20px solid #fff;
border-right: 20px solid #fff;
height: 0px;
width: 200px;
}
Fiddle
Any idea on how or if it's possible to make something like this: .
Something like this:
<span class="outer">
<span class="inner">
<input type="text" value="test value" />
</span>
</span>
.outer {
display: inline-block;
border-bottom: 34px solid #000;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
height: 0px;
}
.inner {
display: inline-block;
margin: 1px -18px -40px -18px;
border-bottom: 32px solid white;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
height: 0px;
}
input
{
background: transparent;
border: none;
display: inline-block;
font-size: 130%;
}
http://jsfiddle.net/fNCt4/4/
The input itself doesn't contribute to the shape. It's only those two spans. You could use the input element itself for the inner shape, but since you need to add markup anyway, I think you might as well add two 'generic' trapezoid helper shapes and leave the input element untouched.
You'll need two to fake the border. This is needed, because the shape itself is created by adding a border, so the visible border is constructed by overlaying a slightly smaller shape onto the other.
The rest is tricks with negative margins to allow the inner shape to be positioned over the border of the outer shape. And of course using transparent as a color, to prevent the 'negative space' of the inner shape to overwrite the outer shape.
Once again clients being complicated!
I suggest you use a background image In the CSS of a trapezium with the outside transparent so a png. Make the margins in a bit so the user doesn't write outside the trapezium.
Hope this helps
You have two options here
CSS3
Image as a background.
for css3 option check out this link http://css-tricks.com/examples/ShapesOfCSS/
#trapezoid {
border-bottom: 100px solid red;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
height: 0; width: 100px;
}
But to make it backward compatible i would suggest you go for image as a background as a fallback for css3.

How to keep button position locked when it is inside a table (mobile webpage)

The position of my "Download" button in the following code depends on the size of the text to the left of it. If the text is long the button gets pushed to the right and if the text is small the button is too far to the left.
<td><p><strong>jk</strong></p><div><p>jk</p></div><span class="rating stars-4"></span></td>
<td><p><strong>Version:2.0</strong></p><a class="button-flat" href = "http://randomdomfile.com/random.txt>Download</a></td>
I have also attached a picture to show what I mean.
Basically, the position of the Version and Download is depending on the size of the title or "jk". I want the button and version to be pushed to the right edge of the screen at all times. How would I do this?
UPDATE: Here's the new code I am using according to what you said:
<td><p><strong>jk</strong></p><div><p>jk</p></div><span class="rating stars-4"></span></td>
<td><div class = "newformat"><p><strong>Version:2.0</strong></p><a class="button-flat" href = "http://randomdomfile.com/random.txt>Download</a></div></td>
.newformat{
position:absolute;
right:0;
}
a.button-flat {
display: block;
line-height: 40px;
height: 40px;
width: 100px;
background: #F6F6F6 url(../images/sprite-button-flat.png) repeat-x 0px 0px;
text-align: center;
border-bottom: 2px solid #D8D8D8;
border-left: 1px solid #D8D8D8;
border-right: 1px solid #D8D8D8;
border-top: 1px solid #D8D8D8;
text-decoration: none;
color: #333333;
padding: 0 .3em;
margin-bottom: 0.5em;
}
Use position:absolute and right:0 on button's CSS.

Border radius not showing

http://thc-cup.ucoz.com/forum/2-1-1
After you can see, the left has a radius at content background and border, but the left one does not! I managed to get it like the one in the left after adding to the div style: display:inline-block; but that messes the box and moves it under the left block.
Since this is a forum (my link) I can't edit html, but I can edit the CSS of the forum.
Here is the style of those blocks:
.postTdInfo { //Left block
display: inline-block;
margin: 0px 0px 0px 35px;
padding: 1px;
border: 1px solid #cfcfcf;
background: #e0e0e0;
border-radius: 5px;
}
.posttdMessage { //Right block
margin: 0px 0px 0px 0px;
padding: 25px;
border: 1px solid #cfcfcf;
background: #e0e0e0;
border-radius: 25px;
I searched all the day for a solution but can't seem to find one.
Is there any way of changing CSS so that the block accepts border radius?
Edit: my first answer didn't solve the problem.
The problem is that you're working on a td element, which has the display property by default set to table. Either add display: block; to .posttdMessage, or, if this causes problems, add another <div> element directly inside the table cell and style that with rounded borders instead.