I want to grow the element background and font on hover. However it does impact all other elements position like the border of the form, elements side.
I tried to do it with the box-shadow but only the shadow is enlarged and not the text.
please Help
LINk: Code for HTML and CSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
text-align: center;
}
.contenedor {
display: inline-block;
width: 400px;
height: 400px;
}
form {
padding: 30px;
border: 1px solid #ccc;
}
input[type="submit"] {
width: 80px;
background: #24b080;
padding: 10px;
border: 1px solid #24b080;
cursor: pointer;
color: white;
margin-top: 10px;
margin-bottom: 10px;
transition: all 0.3s ease-out;
}
input[type="submit"]:hover {
background-color: #24b080;
border: 2px solid #24b080;
color: #fff;
transform: scale(1.2, 1.2);
}
<form name="formulario" action="">
<input type="submit" value="Send">
<input type="submit" value="OK">
<input type="submit" value="Cancel">
</form>
You can change this
form {
padding: 30px;
border: 1px solid #ccc;
}
to this:
form {
padding: 30px;
border: 1px solid #ccc;
height: 120px;
}
If you give the Form a fixed height then it cannot move when the buttons get bigger.
You can apply vertical-align: top; to input[type="submit"] to avoid the slight vertical movement on hover (I guess that's what you meant?):
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
text-align: center;
}
.contenedor {
display: inline-block;
width: 400px;
height: 400px;
}
form {
padding: 30px;
border: 1px solid #ccc;
}
input[type="submit"] {
width: 80px;
background: #24b080;
padding: 10px;
border: 1px solid #24b080;
cursor: pointer;
color: white;
margin-top: 10px;
margin-bottom: 10px;
transition: all 0.3s ease-out;
vertical-align: top;
}
input[type="submit"]:hover {
background-color: #24b080;
border: 2px solid #24b080;
color: #fff;
transform: scale(1.2, 1.2);
}
<form name="formulario" action="">
<input type="submit" value="Send">
<input type="submit" value="OK">
<input type="submit" value="Cancel">
</form>
Related
I'm currently working on a calculator in HTML and have made a form to input various numbers. The form is located in a div that's a sidebar, and I've made a div for each row holding an input and label. However, the input elements are left with a lot of space above them, as well as the borders as they're attached to the input elements. How could I allow the inputs to take up all available vertical space? Picture of extra space
.sidebar {
background-color: #272640;
float: left;
width: 20%;
height: 100%;
position: fixed;
box-sizing: border-box;
display: flex;
flex-direction: column;
border: 1px solid #3E1F47;
}
#sidebarCentered {
}
.siderow {
background-color: #312244;
border-top: 1px solid #3E1F47;
color: white;
padding: 10px;
box-sizing: border-box;
width: 50% text-align:center;
font-family: monaco;
}
.siderow label {}
.siderow input {
box-sizing: border-box;
background-color: #312244;
border: 0px;
height: 100%;
border-left: 1px solid #5A5766;
color: white;
width: 50%;
float: right;
text-align: center;
}
.sidebarbuttons {
background-color: #312244;
margin-top: 10%;
}
.sidebarbuttons input {
background-color: #312244;
font-family: monaco;
font-size: 15px;
margin: 5px;
width: 45%;
color: white;
padding: 10px;
border: 1px solid #3E1F47;
border-radius: 10px;
transition: all ease-in-out 0.15s;
}
.sidebarbuttons input:hover {
background-color: #272640;
color: #272640;
transition: all ease-in-out 0.15s;
}
#centermenu {
background-color: #212F45;
color: #EDFFEC;
overflow: hidden;
text-decoration: none;
border-bottom: 1px solid #5A5766;
box-sizing: border-box;
}
<div class="sidebar">
<form id="sidebarCentered">
<div class="siderow">
<label for="balance">Balance:</label>
<input type="number" name="balance" value=500>
</div>
<div class="siderow">
<label for="monthly">Monthly <br> contribution:</label>
<input type="number" name="monthly" value=0>
</div>
<div class="siderow">
<label for="nummonths">Number of <br> Months:</label>
<input type="number" name="nummonths" value=12>
</div>
<div class="siderow" style="border-bottom:1px solid #3E1F47;">
<label for="ror">Monthly Rate <br> of Return:</label>
<input type="number" name="ror" value=1>
</div>
<div class="sidebarbuttons">
<input type="button" value="Calculate" style="float:left;">
<input type="button" value="Quit" style="float:right;">
</div>
</form>
</div>
That space is caused by padding of 10px in .siderow. I changed the padding to 0 10px which sets top and bottom padding to zero and left/right to 10px. I also added min-width: 200px; to .sidebar for clarity. You may want to change that. Extra vertical space has been removed.
.sidebar {
background-color: #272640;
float: left;
width: 20%;
min-width: 200px;
height: 100%;
position: fixed;
box-sizing: border-box;
display: flex;
flex-direction: column;
border: 1px solid #3E1F47;
}
#sidebarCentered {
}
.siderow {
background-color: #312244;
border-top: 1px solid #3E1F47;
color: white;
padding: 0 10px; /* changed here */
box-sizing: border-box;
width: 50% text-align:center;
font-family: monaco;
}
.siderow label {}
.siderow input {
box-sizing: border-box;
background-color: #312244;
border: 0px;
height: 100%;
border-left: 1px solid #5A5766;
color: white;
width: 50%;
float: right;
text-align: center;
}
.sidebarbuttons {
background-color: #312244;
margin-top: 10%;
}
.sidebarbuttons input {
background-color: #312244;
font-family: monaco;
font-size: 15px;
margin: 5px;
width: 45%;
color: white;
padding: 10px;
border: 1px solid #3E1F47;
border-radius: 10px;
transition: all ease-in-out 0.15s;
}
.sidebarbuttons input:hover {
background-color: #272640;
color: #272640;
transition: all ease-in-out 0.15s;
}
#centermenu {
background-color: #212F45;
color: #EDFFEC;
overflow: hidden;
text-decoration: none;
border-bottom: 1px solid #5A5766;
box-sizing: border-box;
}
<div class="sidebar">
<form id="sidebarCentered">
<div class="siderow">
<label for="balance">Balance:</label>
<input type="number" name="balance" value=500>
</div>
<div class="siderow">
<label for="monthly">Monthly <br> contribution:</label>
<input type="number" name="monthly" value=0>
</div>
<div class="siderow">
<label for="nummonths">Number of <br> Months:</label>
<input type="number" name="nummonths" value=12>
</div>
<div class="siderow" style="border-bottom:1px solid #3E1F47;">
<label for="ror">Monthly Rate <br> of Return:</label>
<input type="number" name="ror" value=1>
</div>
<div class="sidebarbuttons">
<input type="button" value="Calculate" style="float:left;">
<input type="button" value="Quit" style="float:right;">
</div>
</form>
</div>
Give .siderow padding of 0 and add a height to .siderow input and .siderow label.
Next, delete those br tags and add flex to .siderow label so it can be vertically aligned in the middle. Also, don't use inline css.
In all, you will have this:
<div class="sidebar">
<form id="sidebarCentered">
<div class="siderow">
<label for="balance">Balance:</label>
<input type="number" name="balance" value=500>
</div>
<div class="siderow">
<label for="monthly">Monthly contribution:</label>
<input type="number" name="monthly" value=0>
</div>
<div class="siderow">
<label for="nummonths">Number of Months:</label>
<input type="number" name="nummonths" value=12>
</div>
<div class="siderow">
<label for="ror">Monthly Rate of Return:</label>
<input type="number" name="ror" value=1>
</div>
<div class="sidebarbuttons">
<input type="button" value="Calculate" style="float:left;">
<input type="button" value="Quit" style="float:right;">
</div>
</form>
</div>
and the CSS
.sidebar {
background-color: #272640;
float: left;
width: 400px;
height: 100%;
position: fixed;
box-sizing: border-box;
display: flex;
flex-direction: column;
border: 1px solid #5A5766;
}
#sidebarCentered {
}
.siderow {
border-top: 1px solid #5A5766;
color: white;
padding: 0;
box-sizing: border-box;
width: 100%;
text-align:center;
font-family: monaco;
height: auto;
float: left;
}
.siderow:first-child {
border-top: none;
}
.siderow:nth-child(4) {
border-bottom: 1px solid #5A5766;
}
.siderow label {
width: calc(50% - 5px);
float: left;
height: 40px;
display: flex;
align-items: center;
margin-left: 5px;
}
.siderow input {
box-sizing: border-box;
background-color: #272640;
border: 0;
height: 100%;
border-left: 1px solid #5A5766;
color: white;
width: 50%;
float: left;
text-align: center;
height: 40px;
}
.sidebarbuttons {
margin-top: 10%;
}
.sidebarbuttons input {
background-color: #888;
font-family: monaco;
font-size: 15px;
margin: 5px;
width: 45%;
color: white;
padding: 10px;
border: 1px solid #5A5766;
border-radius: 10px;
transition: all ease-in-out 0.15s;
}
.sidebarbuttons input:hover {
background-color: #ccc;
color: #272640;
transition: all ease-in-out 0.15s;
}
#centermenu {
background-color: #212F45;
color: #EDFFEC;
overflow: hidden;
text-decoration: none;
border-bottom: 1px solid #5A5766;
box-sizing: border-box;
}
Link to Fiddle for reference https://jsfiddle.net/kavyw86d/
I'm attempting to make a login page for a website, https://essaydapp.com to submit and try and get into the application. I'm trying to mimic their design (see link) but I'm having some issues:
Screenshots:
https://imgur.com/w2GAphF
https://imgur.com/rimWY0s
In the first screenshot you can see the little 1px dashed border, I would like that to be the height of the entire page rather than the form only.
In the second screenshot you can see on the edges of the page and top there is the white color, but I would like that to be blue too. Thanks for any help in advance.
form {
/*border: 10px solid #1acebc;*/
padding: 28px;
border-left: 1px solid black;
border-left-style: dashed;
border-right: 1px solid black;
border-right-style: dashed;
}
button:hover {
opacity: 0.8;
}
button {
background-color: #09c;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}
input[type=text],
input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #1acebc;
box-sizing: border-box;
}
img {
display: block;
margin: 0 auto;
padding-bottom: 60px;
padding-top: 30px;
width: 300px;
height: 300px;
}
body {
background-color: #e7f3f6;
/*border-left: 250px solid #007da5;
border-right: 250px solid #007da5;*/
border-left: 175px solid #007da5;
border-right: 175px solid #007da5;
padding-top: 175px;
padding-bottom: 215px;
}
<form>
<img src="https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_960_720.png" alt="profilepicture">
<input type="text" placeholder="Username">
<input type="password" placeholder="Password">
<button type="button" name="Login">Login</button>
</form>
This code removes any padding from left and right.
I hope that's what you want.
body{
border: 1px dashed;
backgroud-color: #e7f3f6;
margin-left: 0px;
margin-right: 0px;
}
Your existing code is somewhat messy. Instead, I suggest to use the following flex-box solution
body {
padding: 0;
margin: 0 auto;
background-color: #007da5;
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
form {
display: flex;
width: 75%; /*Set the width required*/
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #e7f3f6;
border-left: 1px dashed black;
border-right: 1px dashed black;
}
img {
width: 300px;
height: 300px;
padding-bottom: 60px;
padding-top: 30px;
}
button:hover {
opacity: 0.8;
}
button {
background-color: #09c;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 85%;
}
input[type=text],
input[type=password] {
width: 85%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #1acebc;
box-sizing: border-box;
}
<form>
<img src="https://i.imgur.com/ihZBCxx.png" alt="profilepicture">
<input type="text" placeholder="Username">
<input type="password" placeholder="Password">
<button type="button" name="Login">Login</button>
</form>
I tried to resize my <fieldset> element, but it automatically made its contents smaller. Then, I added display:inline-block in my CSS file (as suggested by many answers on a similar topic). However, this doesn't help at all, everything stays the same. What should I do? I'd like a noob-friendly solution, since I'm not that good at CSS, as you may have noticed. Cheers!
fieldset {
display: inline-block;
border: 1px solid blue;
background-color: white;
width: 40%;
}
legend {
display: inline-block;
padding: 4px 8px;
border: 1px solid blue;
font-size: 15px;
color: white;
background-color: blue;
text-align: left;
}
label {
width: 100px;
margin-right: 30px;
display: inline-block;
text-align: left;
}
input[type=text] {
width: 25%;
padding: 10px 20px;
margin: 0px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
<fieldset>
<legend>XXX</legend>
<label for="username">Username:</label>
<input type="text" name="username">
</fieldset>
If you use percentage on the content's width, it will will change according to the width of the container(fieldset).
Just remove the percentage value.
fieldset {
display: inline-block;
border: 1px solid blue;
background-color: white;
}
legend {
display: inline-block;
padding: 4px 8px;
border: 1px solid blue;
font-size: 15px;
color: white;
background-color: blue;
text-align: left;
}
label {
width: 100px;
display: inline-block;
text-align: left;
}
input[type=text] {
padding: 10px 20px;
margin: 0px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
<fieldset>
<legend>XXX</legend>
<label for="username">Username:</label>
<input type="text" name="username">
</fieldset>
I am trying to have some pre-input on my forms and I want the input field to expand to the end of the container div. The problem is the input field seems to expand past the container div due to the length of the pre-input text.
.container {
width: 70%;
}
.input-field {
display: inline-block;
white-space: nowrap;
vertical-align: bottom;
background: #fff;
position: relative;
vertical-align: middle;
width: 100%;
min-width: 16px;
border: 1px solid #ddd;
}
.input-field .addon {
padding-left: 8px;
padding-right: 8px;
padding-top: 2px;
padding-bottom: 2px;
text-align: center;
text-shadow: 0 1px 0 #fff;
background: #f0f0f0;
}
.input-field input {
padding-left: 5px;
padding-top: 0;
padding-bottom: 0;
margin: 0;
border: 0;
outline: none;
background: transparent;
resize: none;
width: 100%;
}
.input-field:hover {
border: 1px solid #05c9f0;
}
<div class="container">
<div class="input-field">
<span class="addon">some preinput</span>
<input id="" type="text" name="" value="test text" />
</div>
</div>
Another example here: http://codepen.io/anon/pen/wgdErO
If you try the example code, you will note you can click the input box way outside where I want it to end.
Any thoughts on a fix?
Try using the flexbox layout.
.container {
width: 300px;
}
.input-field {
background: #fff;
border: 1px solid #ddd;
display: flex;
align-items: center;
}
.input-field .addon {
padding: 2px 8px;
text-shadow: 0 1px 0 #fff;
background: #f0f0f0;
}
.input-field input {
padding: 0 4px;
margin: 0;
border: 0;
outline: none;
background: transparent;
resize: none;
flex: 1;
}
.input-field:hover {
border: 1px solid #05c9f0;
}
<div class="container">
<div class="input-field">
<span class="addon">some preinput</span>
<input id="" type="text" name="" value="test text" />
</div>
</div>
<img src="//dummyimage.com/300x50">
Just decrease the input width from 100% to a lower value like 99.7% and that will do the trick:
.container {
width: 70%;
border: 1px solid red;
}
.input-field {
display: inline-block;
white-space: nowrap;
vertical-align: bottom;
background: #fff;
position: relative;
vertical-align: middle;
width: 99.7%;
min-width: 16px;
border: 1px solid #ddd;
}
.input-field .addon {
padding-left: 8px;
padding-right: 8px;
padding-top: 2px;
padding-bottom: 2px;
text-align: center;
text-shadow: 0 1px 0 #fff;
background: #f0f0f0;
}
.input-field input {
padding-left: 5px;
padding-top: 0;
padding-bottom: 0;
margin: 0;
border: 0;
outline: none;
background: transparent;
resize: none;
width: 100%;
}
.input-field:hover {border: 1px solid #05c9f0;}
<div class="container">
<div class="input-field">
<span class="addon">some preinput</span>
<input id="" type="text" name="" value="test text" />
</div>
</div>
You can calculate the width like this! width: calc(100% - 125px); rather than set it to 100%
What i am doing is that in search box when user enter a search term, i display a close button ('x' character to be specific, embedded as content after reset button) to clear the contents of search box.
It works fine in both Chrome and IE but not in firefox.
Any kind of help would be highly appreciated.
.search-box,.close-icon,.search-wrapper {
position: relative;
padding: 10px;
}
.search-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.search-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 2px solid #bebede;
}
.close-icon {
border:1px solid transparent;
background-color: transparent;
display: inline-block;
vertical-align: middle;
outline: 0;
cursor: pointer;
}
.close-icon:after {
content: "X";
display: block;
width: 15px;
height: 15px;
position: absolute;
z-index:1;
right: 35px;
top: 0;
bottom: 0;
margin: auto;
padding: 2px;
border-radius: 50%;
text-align: center;
color: black;
font-weight: normal;
font-size: 12px;
cursor: pointer;
}
.search-box:not(:valid) ~ .close-icon {
display: none;
}
<div class="search-wrapper">
<form>
<input type="text" name="focus" required class="search-box" placeholder="Enter search term" />
<button class="close-icon" type="reset"></button>
</form>
</div>
This code should help you
.search-box,.search-wrapper {
position: relative;
padding: 10px;
}
.search-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.search-box
{
width:300px;
}
.search-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 2px solid #bebede;
}
.close-icon {
border:1px solid transparent;
background-color: transparent,
display: inline-block;
vertical-align: middle;
outline: 0;
position: absolute;
top:19px;
left:305px;
z-index:1;
padding: 1px 2px;
border-radius: 50%;
text-align: center;
color: black;
font-weight: normal;
font-size: 12px;
cursor: pointer;
}
.search-box:not(:valid) ~ .close-icon {
display: none;
}
<div class="search-wrapper">
<form>
<input type="text" name="focus" required class="search-box" placeholder="Enter search term" />
<button class="close-icon" type="reset">X</button>
</form>
</div>
NOTE : set your .search-box width and according to it set left of your .close-icon
Try this code: Hope this solve your problem. Adjust "outer_box" class for width.
<style>
.search-box, .search-wrapper {
padding: 10px;
box-sizing: border-box;
}
.search-box {
position:relative;
width:100%;
}
.outer_boxs{
position:relative;
width:60%;
}
.search-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.search-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 2px solid #bebede;
}
.close-icon {
border:1px solid transparent;
background-color: transparent,
display: inline-block;
vertical-align: middle;
outline: 0;
cursor: pointer;
position: absolute;
right:5px;
top: 10px;
background:#f2f2f2;
}
.search-box:not(:valid) ~ .close-icon {
display: none;
}
</style>
<div class="search-wrapper">
<form>
<div class="outer_boxs" >
<input type="text" name="focus" required class="search-box" placeholder="Enter search term" />
<button class="close-icon" type="reset">X</button>
</div>
</form>
</div>