I have a project to create a website designed in PhotoShop. I want to create a to textbox in HTML and CSS which looks like this:
As you can see, there is no problem with the background or fonts; the problem is the textbox. How can I create textboxes with these curves?
* {
box-sizing: border-box;
-moz-box-sizing: border-box;
}
div {
background: #444;
direction: rtl;
width: 300px;
padding: 20px;
}
label {
width: 100%;
color: #fff
}
input {
border-radius: 0 2em;
padding: 0 10px;
width: 100%;
border: none;
line-height: 2em;
margin-bottom: 20px;
}
textarea {
border-radius: 0 4em;
padding: 0 10px;
width: 100%;
border: none;
line-height: 2em;
margin-bottom: 20px;
}
input[type="submit"] {
max-width: 100px;
}
<div class="wrapper">
<label>Name</label>
<input type="text" />
<label>Email</label>
<input type="text" />
<label>Message</label>
<textarea></textarea>
<input type="submit" value="Submit" />
</div>
This is how to get the shape in your image. You will need to learn a bit about border-radius.
The following is an example:
div#test {
border: thin solid #666;
width: 8em;
height: 2em;
border-radius: 0 2em 0 2em;
}
<div id="test"> </div>
The border-radius property is responsible for rounding corners. It can be very sophisticated, but the simple one here will do the job. You will just need to adjust some of the values.
The four values in the border-radius property represent the radius of the individual borders, clockwise from the top-left corner.
Related
This question already has answers here:
How to make an element width: 100% minus padding?
(15 answers)
Closed 3 years ago.
I'm trying to edit the form text padding without changing the form size (to match the placeholder). Every time I change the padding it adds the form's length.
.form-wrapper {
display:flex;
justify-content: center;
flex-direction: column;
margin: 1em 6em;
}
form {
width:100%;
margin: 1em 0;
}
.email-input input{
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom: none;
}
.password-input input{
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
input {
width:100%;
height: 50px;
border:solid 1px #ccc;
font-size:18px;
}
input::placeholder {
color: #ccc;
font-size:18px;
padding-left:25px;
}
<form>
<div className="input-field email-input">
<input id="email" type="text" className="validate" placeholder="Enter Your Email Adress"/>
</div>
<div className="input-field password-input">
<input id="password" type="text" className="validate" placeholder="Enter Your Password"/>
</div>
</form>
Adding something as :
input {
padding-left: 25px;
}
Increases the form length which is undesirable. Is this something I have to end up hacking through to make work?
You may want to use CCS box-sizing
That will include the border and padding to the elements width
* {
box-sizing: border-box;
}
be careful with the * you can also add box-sizing: border-box; to only the elements needed.
Add *{box-sizing: border-box;} for global css it will not increase the padding outside the
An alternative to box-sizing: border-box; might be toe substract the padding from width, something like this:
.form-wrapper {
display: flex;
justify-content: center;
flex-direction: column;
margin: 1em 6em;
}
form {
width: 100%;
margin: 1em 0;
}
.email-input input {
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom: none;
}
.password-input input {
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
input {
width: calc(100% - 25px);
height: 50px;
border: solid 1px #ccc;
font-size: 18px;
padding-left: 25px;
}
input::placeholder {
color: #ccc;
font-size: 18px;
padding-left: 25px;
}
<form>
<div className="input-field email-input">
<input id="email" type="text" className="validate" placeholder="Enter Your Email Adress" />
</div>
<div className="input-field password-input">
<input id="password" type="text" className="validate" placeholder="Enter Your Password" />
</div>
</form>
How can i hide border behind MON and give some space like in this pic
https://www.screencast.com/t/SJmg63NZuF
div {
height: 100px;
width: 100px;
border: 2px solid black;
}
h2 {
width: 50px;
margin-top: -15px;
margin-left: 0px;
padding: 0 10px;
}
<div>
<h2>MON</h2>
<p>7am - yeah</p>
</div>
I think you're trying to achieve this. The convention of using <legend> tags which is a child of <fieldset> is usually applied and used for forms but you can achieve the same as shown below. I tweaked the code a bit and added a background to show you how you may achieve what you're looking for as the screenshot you posted.
Hope, it helps.
body {
background-image: url("https://ak9.picdn.net/shutterstock/videos/21522739/thumb/1.jpg");
}
fieldset {
width: 100px;
border: 2px solid white;
text-align: center;
}
h2 {
color: white;
}
p {
color: white;
}
<fieldset>
<legend align="center">
<h2>MON</h2>
</legend>
<p>7am - yeah</p>
<p>8am - yeah</p>
<p>9am - yeah</p>
</fieldset>
Looks like you just need to set the background color from transparent.
div {
height: 100px;
width: 100px;
border: 2px solid black;
background: white;
}
h2 {
width: 50px;
margin-top: -15px;
margin-left: 8px;
padding: 0 14px 0 10px;
background: white;
}
<div>
<h2>MON</h2>
<p>7am - yeah</p>
</div>
I have the fiddle here: https://jsfiddle.net/ufLpqdtj/
My problem is trying to get my search box and button to always sit full width on the page regardless of the device it is running on.
In Javascript I could always make the text box width 100% minus the pixel width of the button (the button is always the same size) but I feel as if im missing something and that it can be done natively in CSS.
Any thoughts or suggestions?
#commonSearchContainer {
display: block;
clear: both;
width: 100%;
position: relative;
}
#commonSearchTerm {
width: 100%;
margin: 25px 0px 0px 0px;
padding: 5px;
border: 1px solid #999999;
height: 35px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.common-search-term-wrapper {
width: 90%;
display: inline-block;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.common-search-button {
background-color: #E9700D;
border: 1px solid #ccc;
display: inline-block;
margin: 25px 0px 0px 10px;
width: 80px;
color: #fff;
padding: 7px;
font-style: italic;
cursor: pointer;
}
<div id="searchSection" class="common-search-section">
<div class="common-search-term-wrapper">
<input id="commonSearchTerm" type="text" autocomplete="off" class="common-search-term">
</div>
<div id="commonSearchSubmit" class="common-search-button">
Search
<div style="clear: both;"></div>
</div>
</div>
What I typically do for that sort of layout is make a parent container around the elements (like you have) and give it position: relative and width: 100%.
Then I use position: absolute and display: inline-block on the inner elements. Set the width for the fixed-sized elements and use left or right to position all of the elements.
In your case, it would be something like this: https://jsfiddle.net/ufLpqdtj/1/
Well you shouldn't use the div as a button. There are html elements for that.
If correctly understood what you want to achieve...
form {
width: 100%;
display: inline-flex;
justify-content: center;
}
#commonSearchTerm {
width: 80%;
}
#searchButton {
width: 80px;
border-radius: 0;
background-color: red;
border: none;
padding: 2px;
color: white;
}
<form >
<input id="commonSearchTerm" type="text" autocomplete="off" class="common-search-term">
<input id="searchButton" type="submit">
</form>
This is using flexbox which is is more flexible when creating responsive stuff.
I am having a problem in which a the post button for a text box is being pushed down when the screen is resized as demonstrated in the pictures:
From this:
To this:
The width of the text box is 83% and the width of the post button is 14% which adds up to 97%. I thought with a liquid layout, as long as the width percentages do not go over 100%, you are fine? Can someone explain why this is happening as I cant seem to figure it!
Here is my HTML:
<div class="pageWrapper">
<div class="newsfeedPostForm">
<form action="public_posts.php" method="POST">
<textarea id="newsfeedPost" name="post" rows="5" cols="90"></textarea>
<input type="submit" name="send" class="postFormSubmit" value="Post">
</form>
</div>
<div>
And my CSS:
#pageWrapper {
width: 56%;
padding-left: 10px;
padding-right: 10px;
border-left: 1px solid #cad3dc;
border-right: 1px solid #cad3dc;
}
.newsfeedPostForm {
width: 71%;
height: 77px;
background-color: #e5e6e7;
padding: 5px;
margin-bottom: 3px;
}
#newsfeedPost {
background-color: #FFFFFF;
width: 83%;
max-height: 66px;
margin-top: 4px;
margin-left: 4px;
font-weight: bold;
}
.postFormSubmit {
background-color: #DCE5EE;
position:relative;
float: right;
width: 14%;
height:69px;
margin-right: 4px;
}
Use box-sizing: border-box on .newsfeedPostForm. That should solve your problem.
.newsfeedPostForm {
box-sizing: border-box;
.....
}
You can read here for more information on box-sizing and the problem it solves.
1st sorry if the title is not 100% at the pont, i really have no idea how to compose it.
Anyway here is a simple problem with 100% width layout. I have a form that is inside a fluid container, it has - 1 input, 1 select, 1 button, they all are align inline (horizontal)
the problem when i minimize the window the button and then the select list they move down. which i dont want that.
Here is a example in the fiddle http://jsfiddle.net/4GSLE/ you can minimize the html part and you will see the problem.
How to make them to be in one line and not to move down?
.main {
max-width: 1200px;
margin: 0px auto;
background-color: #eee;
line-height: 50px;
padding: 10px;
}
form {
padding: 0 0 0 0;
margin: 0 0 0 0;
display: block;
}
.clear {clear: both;}
input, select {
float: left;
height: 50px !important;
padding: 0 10px;
width: 66% !important;
border: 1px solid #d6d8db;
margin-right: 20px;
}
input.button {
height: 54px !important;
padding: 0 10px;
margin-top: -1px !important;
width: 125px !important;
border: 1px solid #d6d8db !important;
background: #333;
cursor: pointer;
color: #fff;
}
select {
width: 200px !important;
height: 52px !important;
}
html:
<div class="main">
<form>
<input type="text" name="" value="search" />
<select>
<option>select</option>
</select>
<input type="submit" name="" value="Search now" class="button" />
</form>
<div class="clear"></div>
</div>
Some CSS tweaking to the form, input, and select selectors should do the trick.
form {
padding: 0;
margin: 0;
display: block;
white-space: nowrap;
}
input, select {
display: inline-block;
height: 50px;
padding: 0 10px;
width: 66%;
border: 1px solid #d6d8db;
margin-right: 20px;
}
Demo Here
Side note: Unless you really need them, all those !important declarations will end up causing more trouble than solving issues. I'd avoid !important as much as possible.