I'm trying to make a login form with block icons before the input fields.
#import url(http://meyerweb.com/eric/tools/css/reset/reset.css);
#import url(http://weloveiconfonts.com/api/?family=fontawesome);
[class*="fontawesome-"]:before {
font-family: 'FontAwesome', sans-serif;
}
#login {
margin: 50px auto;
width: 300px;
background: #999;
padding: 50px;
}
#login p {
line-height: 50px;
}
#login p span {
display: inline-block;
width: 30px;
height: 30px;
line-height: 30px;
padding: 3px;
text-align: center;
border: 1px solid #ccc;
background: #ccc;
color: #fff;
}
#login p input {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
padding: 3px;
width: 200px;
height: 30px;
line-height: 30px;
border: 1px solid #ccc;
background: #fdfdfd;
}
html
<div id="login">
<p><span class="fontawesome-user"></span><input type="text" placeholder="Username"></p>
<p><span class="fontawesome-lock"></span><input type="password" placeholder="Password"></p>
</div>
Unfortunately, I can not precisely align the block (span) icon with the input field. How could I do this? thanks
Example
You need to vertical-align the inline-block elements, eg :
#login p > * {
vertical-align:middle;
}
Forked Fiddle
Related
I'm trying to put a border in a button, I tried to create 2 div and then do display: inline-block but it doesn't work, here is my code:
`#vid {
position: absolute;
width: 95px;
height: 60px;
background-color: #ffff;
border: #ffff;
font-size: 13px;
font-family: Arial, Helvetica, sans-serif;
display: inline-block;
}
#h5-vid {
border-radius: 25px;
background: #ffff;
border-color: black;
display: inline-block;
}
<button id="vid"><p>Videos</p><div id="h5-vid"><h5 id="h5-text-vid">New!</h5></button></div>`
This is what I want to get:
This is what I got:
Put both elements with text inside the button:
<button id="vid">
<p>Videos</p>
<h5 id="h5-text-vid">NEW</h5>
</button>
Use display: flex; with justify and align center for the button then simply add border to the h5 element using border: solid 1px black;
Here is a working snippet:
#vid {
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
width: 95px;
height: 60px;
background-color: #ffff;
border: none;
font-size: 13px;
font-family: Arial, Helvetica, sans-serif;
}
#h5-text-vid {
border: solid 1px black;
border-radius: 25px;
padding: 3px;
font-size: 6pt;
font-weight: 800;
}
body {
/* Just for demo */
background-color: gray;
}
<button id="vid">
<p>Videos</p>
<h5 id="h5-text-vid">NEW</h5>
</button>
Your code didn't work because p tag is block element.
And also p and h5 tag has margin-block-start and margin-block-end.
So I removed those margins, and set display: inline-block to p tag.
Now, it works.
Note: You set border-color to div#h5-vid, but didn't work because div doesn't have border in default.
So I changed it as border: 1px solid black.
p, h5 {
margin-block-start: 0;
margin-block-end: 0;
display: inline-block;
}
#vid{
position: absolute;
width: 95px;
height: 60px;
background-color: #fff;
border: #fff;
font-size: 13px;
font-family: Arial, Helvetica, sans-serif;
display: inline-block;
}
#h5-vid{
border-radius: 25px;
background: #fff;
border: 1px solid black;
display: inline-block;
margin-left: 5px;
padding: 0 3px;
}
<button id="vid"><p>Videos</p><div id="h5-vid"><h5 id="h5-text-vid">New!</h5></div></button>
I want to style a <button> and <a> element both into the same format. I use the following code:
button,
a {
border: solid 1px black;
background-color: white;
color: black;
font-family: 'Arial';
padding: 0 15px;
font-size: 13px;
height: 35px;
line-height: 35px;
display: inline-block;
}
#dummy-block {
background-color: black;
padding: 0;
margin: 0;
height: 20px;
}
<div id="dummy-block"></div>
<button>My Button</button>
<a>My Link</a>
But the <button> element seems to ignore the height and my <a> element does not touch the edge of the black dummy <div> above:
You can test the code in my fiddle: http://jsfiddle.net/gyrrcrqc/1/
Try this:-
button, a {
background-color: white;
border: medium none;
box-shadow: 0 0 1px #000 inset;
color: black;
display: inline-block;
font-family: "Arial";
font-size: 13px;
height: 35px;
line-height: 35px;
padding: 0 15px;
vertical-align: top;
}
Or:-
button, a {
background-color: white;
border: medium none;
vertical-align:top;
color: black;
display: inline-block;
font-family: "Arial";
font-size: 13px;
height: 35px;
line-height: 35px;
padding: 0 15px;
border:1px solid #000;
box-sizing:border-box
}
DEMO2
DEMO
Apparently the default box-sizing method for button is border-box while that for inline-block is content-box. So:
35px height means the <a> is actually 37px tall (border adds 2px)
35px height means the <button> tag is 35px tall (35px includes the border)
Set the box-sizing: border-box on both elements.
button,
a {
border: solid 1px black;
background-color: white;
color: black;
font-family: 'Arial';
padding: 0 15px;
font-size: 13px;
height: 35px;
line-height: 35px;
display: inline-block;
box-sizing: border-box;
}
#dummy-block {
background-color: black;
padding: 0;
margin: 0;
height: 20px;
}
<div id="dummy-block"></div>
<button>My Button</button>
<a>My Link</a>
try adding vertical-align: bottom to button, a selector
button, a
{
border: solid 1px black;
background-color: white;
color: black;
font-family: 'Arial';
padding: 0 15px;
font-size: 13px;
height: 35px;
line-height: 35px;
display: inline-block;
vertical-align: top;
}
#dummy-block
{
background-color: black;
padding: 0;
margin: 0;
height: 20px;
}
<div id="dummy-block"></div>
<button>Okay</button>
<a>Edit</a>
a
{
padding:1px 15px;
}
button,a
{
border: solid 1px black;
background-color: white;
color: black;
font-family: 'Arial';
font-size: 13px;
height: 35px;
line-height: 35px;
display: inline-block;
}
button
{
padding: 0 15px;
}
So I have a label and a field. But for some reason they don't seem to align. Here's my markup
<span class="hash">#</span>
<input type="text" class="hex" maxlength="6">
And the CSS.
.hex {
width: 385px;
height: 40px;
font-size: 30px;
font-family: 'proxima_novalight';
outline: none;
background: none;
border: 3px solid black;
}
.hash {
font-size: 51px;
font-family: 'proxima_novalight';
}
I want to align the # with the field. I've tried line-height, but that didn't work. Here's a demo
You need to set vertical-align:middle for both the elements:
.hex {
width: 385px;
height: 40px;
font-size: 30px;
font-family: 'proxima_novalight';
outline: none;
background: none;
border: 3px solid black;
vertical-align:middle; /* add this */
}
.hash {
font-size: 51px;
font-family: 'proxima_novalight';
vertical-align:middle; /* add this */
}
Demo
http://i.imgur.com/Sc1NnFp.png
I need to create that with CSS. I can use an image if absolutely necessary, but either way it needs to be expandable (probably vertically is best for this one).
http://jsfiddle.net/VR2WF/
<div id="cta">
<div class="callus">Call us today!</div>
<div class="phonenumber">404-555-5555</div>
</div>
#cta {
font-family: Arial, sans-serif;
font-weight: bold;
font-size: 20px;
padding: 10px 20px;
color: #FFF;
text-align: center;
text-transform: uppercase;
background: #232323;
max-width: 400px;
margin: auto;
}
.callus, .phonenumber {
display: inline-block;
}
Here is my solution:
http://codepen.io/Chovanec/pen/temKh
<div class="rib"><div class="text">Call us today</div><div class="arrow"><!-- --></div></div>
.rib .text {
font-family: sans-serif;
color: #fff;
background: #000;
padding: 20px 50px 5px 50px;
width: 500px;
font-size: 20px;
text-transform: uppercase;
font-weight: bold;
text-align: center;
}
.rib .arrow {
display: block;
border-width: 20px 300px 0 300px;
border-color: transparent;
border-top-color: #000;
border-style: solid;
height: 0;
width: 0;
overflow: hidden;
}
I'm not sure why, but I get this text showing / flowing outside of the <h3> tag. I thought it was something to do with floats, but I have tried all the solutions I know to fix it and they haven't worked.
Here is jsfiddle (I'm in Safari): http://jsfiddle.net/BJCkv/1/
HTML :
<div id="header-container">
<div class="wrapper"> <!-- has width of 940px; and aligned in middle -->
<h1>PCSA - TRAINING</h1>
<h3>Security Architecture</h3> <!-- This is the problem text -->
</div>
</div>
CSS :
#header-container {
height: 84px;
line-height: 84px;
background-color: #e0dfd9;
background-image: url(../img/header.png);
border-top: 1px solid #ccccc7;
border-bottom: 1px solid #ccccc7;
}
#header-container .wrapper {
overflow: hidden;
}
#header-container h1 {
color: #b8622b;
font-family: 'Open Sans', sans-serif;
font-size: 38px;
text-shadow: 0 1px 0 #f7f7f5;
font-weight: 600;
float: left;
background: red;
}
#header-container h3 {
color: #a5a5a4;
float: left;
font-family: 'Open Sans', sans-serif;
font-style: italic;
padding: 3px 0 3px 10px;
margin-left: 20px;
height: 30px;
border-left: 1px solid #a5a5a4;
background: yellow;
}
You can replace height: 30px; with line-height: 30px; That should solve the problem.
http://jsfiddle.net/BJCkv/7/
You need to reset the line-height for the h3 element: Live demo: http://jsfiddle.net/BJCkv/5/
#header-container h3 {
line-height: 30px; /* add this */
color: #a5a5a4;
float: left;
font-family: 'Open Sans', sans-serif;
font-style: italic;
padding: 3px 0 3px 10px;
margin-left: 20px;
height: 30px;
border-left: 1px solid #a5a5a4;
background: yellow;
}