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.
Related
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.
I have two input fields in a form on my website. I have designed them to have only the bottom-border and applied the following other css:
input {
-webkit-appearance: none;
appearance: none;
border: none;
}
.loginTextField {
background-color: rgba(255, 255, 255, 0.1);
border-radius: 5px;
border-bottom: 2px solid white;
outline: none;
}
The text fields look like this, in HTML: (Also note, there is no div with the same size behind the text field.)
<input type="email" class="loginTextField" id="loginEmail">
Currently, even though only the bottom border is set, Safari renders the text fields the following way - notice the top corners having those white pixels:
(it's easier to see on this one)
Chrome, on the other hand, renders them as desired:
I know, a similar question has been asked before. However, none of the proposed solutions work for me.
I have already tried doing something like:
border: 0 solid transparent;
border-bottom: 2px solid white;
and:
border-top: 0 solid transparent;
border-right: 0 solid transparent;
border-bottom: 2px solid white;
...without any luck.
I did notice, however, that changing the bottom-border-color to, say, green, also changes those extra pixels to that color.
Check out this working JSFiddle example.
Is there a way to have Safari not render those white pixels?
I've added box-shadow: inset 10px 10px #000; in parent element
Before:
After:
i want to add border to the bootstrap form box.i had added border style properties but its not working . suggest please
thia is the form box class:
<div class="form-box">
<div class="form-top">
<div class="form-top-left">
And this is the css :
.form-box {
margin-top: 0px;
border-radius: 25px;
border-bottom-style: solid;
border-color: #50e54b;
}
Because of other classes, use the "!important"
border: solid 2px #50e54b!important;
You can add border to your box by using the border CSS property [border](https://developer.mozilla.org/en-US/docs/Web/CSS/border)
Here's an example usage:
border: 1px solid #FFFFFF;
The code above will add a solid border of 1px in thickness and white in colour.
Click the link above to see more about the border property.
From what I can tell, the code works fine. But if you want you can add an 8px padding so the content has room for placement instead of being crammed in there with the border. By the way, a 2px or 4px border radius looks better for the border, but it's up to you.
.form-box {
padding: 8px; /*makes it look neat*/
border-radius: 4px; /*or 2px*/
border: 1px solid red;
}
I'm new with css, but the thing that i'm trying to do is slightly complicated, at least for me. I have a picture that i want to cover with a circle, transparent from the inside, black from the outside.
this is what I've accomplished so far:
.roundedBorder {
border: 1px solid #1EC865;
border-width: 4px;
border-radius: 81px;
}
.img { position:absolute; top:6px; left:6px; width:81px;
}
<img class=img src="http://suptg.thisisnotatrueending.com/archive/13559636/images/1295334728830.jpg">
<div style="position:absolute;width:70px;height:70px;border-width: 4px;position:absolute;" class="roundedBorder">
</div>
https://jsfiddle.net/dmL56kek/
now i'm looking to cover the outer of circle with a solid color.
PS: i don't want to apply any style on the image because it won't work in my case.
A little change is css would help and i have used width:78px with a calculation that width of outer div is 70px and border is 4px from left and right.
.roundedBorder {
border: 1px solid #1EC865;
border-width: 4px;
border-radius: 81px;
}
.img { position:absolute; top:8px; left:8px; width:78px; border-radius:100%;}
<img class=img src="http://suptg.thisisnotatrueending.com/archive/13559636/images/1295334728830.jpg">
<div style="position:absolute;width:70px;height:70px;border-width: 4px;position:absolute;" class="roundedBorder">
</div>
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.