CSS form doesn't appear to have any line breaks - html

I'm working on styling my website forms and found a tutorial that seems to work up to a point... The tutorial includes code to have hover hints, and this code is causing things to get ugly. Instead of the fields all lining up under one another they seem to be attempting to position themselves one right after another and wrapping all the way down the window.
Here is the code element for the feature in question followed by the CSS...
HTML
<form id="defaultform" class="rounded" name="form2" method="post" action="<?php echo $editFormAction; ?>">
<h3>Contact Form</h3>
<div class="field">
<label for="hostess_fname">First Name:</label>
<input type="text" class="input" name="hostess_fname" value="" id="hostess_fname" />
<p class="hint">Enter your name.</p>
</div>
<div class="field">
<label for="email">Last Name:</label>
<input type="text" class="input" name="hostess_fname" value="" id="hostess_lname" />
<p class="hint">Enter your email.</p>
</div>
<input type="submit" value="Lookup Hostess" />
<input type="hidden" name="Lookup" value="form2" />
CSS
#defaultform {
width: 500px;
padding: 20px;
background: #f0f0f0;
overflow:auto;
/* Border style */
border: 1px solid #cccccc;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
border-radius: 7px;
/* Border Shadow */
-moz-box-shadow: 2px 2px 2px #cccccc;
-webkit-box-shadow: 2px 2px 2px #cccccc;
box-shadow: 2px 2px 2px #cccccc;
}
label {
font-family: Arial, Verdana;
text-shadow: 2px 2px 2px #ccc;
display: block;
float: left;
font-weight: bold;
margin-right:10px;
text-align: right;
width: 120px;
line-height: 25px;
font-size: 15px;
}
#defaultform.input{
font-family: Arial, Verdana;
font-size: 15px;
padding: 5px;
border: 1px solid #b9bdc1;
width: 300px;
color: #797979;
}
.hint{
display: none;
}
.field:hover .hint {
position: absolute;
display: block;
margin: -30px 0 0 455px;
color: #FFFFFF;
padding: 7px 10px;
background: rgba(0, 0, 0, 0.6);
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
border-radius: 7px;
}
I just updated the code with more of the HTML from a shorter form that I was trying with the same CSS. I also added some more of the CSS code. I'm getting the same behavior. I'm still confused on selectors and how those are defined and stuff.

I see what you're doing now that you've added your code. It's a pretty simple fix, but hard to catch:
CSS
.field{
clear:both;
}
Here's the jsFiddle

Related

Input not clickable

.contact-form {
transition: .3s;
margin-top: 120px;
/*border: 2px solid black;*/
background-color: rgb(243, 243, 243);
border-radius: 6px;
box-shadow: -4px 12px 11px 5px rgba(0, 0, 0, 0.521);
width: 475px;
height: 550px;
margin-left: 11px;
text-align: left;
align-items: center;
position: sticky;
left: 60%;
top: -20%;
user-select: all;
z-index: 4;
}
.benefit-card {
margin: 20px;
background-color: white;
text-align: center;
border: 1px solid black;
width: 300px;
height: 450px;
top: 0%;
left: 22%;
box-shadow: 2px 2px 12px 2px black;
user-select: none;
}
.benefit-card-header {
border-bottom: 3px dotted black;
padding-bottom: 11px;
}
.benefit-card-image {
-webkit-user-drag: none;
padding-top: 11px;
padding-bottom: 19px;
width: 200px;
filter: drop-shadow(2px 2px 6px black);
}
#help-me {
position: relative;
z-index: 8;
margin-top: -515px;
}
<div class="contact-form">
<h2 class="contact-form-header">Get Your Quote Today!</h2>
<form class="form-bg-pls-send-help">
<label class="contact-input-header" for="email">Email<span class="important-contact-field"> *</span></label>
<br>
<input class="contact-input" name="email" type="email" autocomplete="off" required placeholder="Your company email" />
<label class="contact-input-header" for="company">Company</label>
<br>
<input class="contact-input" name="company" type="text" required placeholder="Who do you work for?" />
<label class="contact-input-header" for="subject">Subject</label>
<input class="contact-input" name="subject" type="text" placeholder="Subject " />
<label class="contact-input-header" for="about">About</label>
<textarea class="long-input contact-input" name="about" type="text" placeholder="What does your company do?"></textarea>
<br><br>
<input class="getquote-button" type="submit" value="Get Quote" />
</form>
</div>
<div id="help-me">
<div class="benefit-card" id="bc">
<h1 class="benefit-card-header" id="bch">World Wide</h1>
<h3 class="benefit-card-description" id="bcd">No matter where you're from or where you're located we will help you grow your company!</h3>
</div>
</div>
I am building a sample website of a company. I have a contact form set up, but the inputs are not clickable when they are in a div tag, but I need the form in one so I can properly style the form.
The form is supposed to require the input, when I click on the Get Quote button it allows me to edit the first input tag. This has never happened to me before and I have tried user-select, checking if the disabled attribute was used, and just about everything I can think of.
Update your css file to:
#help-me{
position: relative;
z-index: -1;
margin-top: -515px;
}
This element is covering the whole screen.
Update the z-index when you need to show it.
Your inputs are not clickable because #help-me covers all of .contact-form due to the way you have used margin-top to position it higher compared to where it would naturally sit.
Consider using flexbox to achieve your layout instead.
.layout {
display: flex
}
.contact-form {
flex: 1 1 auto;
background-color: rgb(243, 243, 243);
border-radius: 6px;
box-shadow: -4px 12px 11px 5px rgba(0, 0, 0, 0.521);
}
#help-me {
flex: 1 1 auto;
}
<div class="layout">
<div id="help-me">
#help-me
</div>
<div class="contact-form">
.contact-form
</div>
</div>

How do I make CSS sharp "V" like horizontal corners for `<legend>` and `<fieldset>`?

How do I make in CSS sharp "V" like horizontal corners?
Corners that look like this < > as if the corners were arose to left and right in both the <legend> and then in the <fieldset> as well.
#FieldsetSeekBox {
padding: 8px 1px;
border: 1px solid #a1a1a1;
}
#LegendStyle {
border-style: none;
background-color: #a1a1a1;
font: bold 13px Tahoma, Arial, Helvetica;
color: #000000;
padding-left: 10px;
position: relative;
border-radius: 8px 8px 0px 0px;
}
<fieldset id="FieldsetSeekBox">
<legend id="LegendStyle"> Web Search </legend>
<input type="text" name="u" size="70" value="" placeholder="Type your Search here and click Search..." id="SeekBox">
</fieldset>
In general, you need to set some content with the css pseudo elements :before or :after. Then by setting the border widths for top/bottom you can create a triangle shape.
See css-triangle demo, or below example.
#FieldsetSeekBox {
padding: 8px 1px;
border: 1px solid #a1a1a1;
}
#LegendStyle {
border-style: none;
background-color: #a1a1a1;
font: bold 13px Tahoma, Arial, Helvetica;
color: #000000;
padding-left: 10px;
position: relative;
}
#LegendStyle:after {
content: " ";
display: block;
position: absolute;
right: -10px;
top: 0;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
border-left: 10px solid #a1a1a1;
}
<fieldset id="FieldsetSeekBox">
<legend id="LegendStyle"> Web Search </legend>
<input type="text" name="u" size="70" value="" placeholder="Type your Search here and click Search..." id="SeekBox">
</fieldset>

css messed up (auto height) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have a problem with a css style. It happen when I set height to auto website
access live view by diung this go to newproject.comli.com/post.php log in with a username = shining password = asdfgh123 and then manualy go to newproject.comli.com/details.php
so my div height gets set to 0 do not know why. I am talking about #itemsCategListsform could someone help me? Here is my code:
<div id="itemsCategListsform">
<div id="plink">
<div id="open">My details</div>
<div id="closed">My ads</div>
<div id="closed">Favorites</div>
</div>
<div id="pbase">
<div id="detailforms">
<p> Email:
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<input type="email" name="email" size="30">
<input class="submit-buttonform" type="submit" name="updateemail" value="Update Email">
</form>
</p>
<p>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
Password: <br>
<input type="password" name="password" size="30"><br>
Re-Password: <br>
<input type="password" name="repassword" size="30">
<input class="submit-buttonform" type="submit" name="updatepassword" value="Update password" >
</form>
</p>
Phone:
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<input type="text" name="phone" size="30">
<input class="submit-buttonform" type="submit" name="updatephone" value="Update phone">
</form>
Website:
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<input type="text" name="website" size="30">
<input class="submit-buttonform" type="submit" name="updatewebsite" value="Update website">
</form>
</div>
</div>
</div>
and css :
#itemsCategListsform {
background-color: white;
position: relative;
width: 930px;
height: auto;
left: 175px;
top: 20px;
border-radius: 4px;
border: 1px solid #1a171a;
padding-top: 40px;
padding-left: 70px;
-webkit-box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.6);
-moz-box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.6);
box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.6);
}
#plink {
position: relative;
width: 200px;
float: left;
border-top: 1px solid black;
border-left: 1px solid black;
z-index: 10;
border-radius: 4px 0 0 4px;
-webkit-box-shadow: -3px 3px 5px -3px rgba(0,0,0,0.6);
-moz-box-shadow: -3px 3px 5px -3px rgba(0,0,0,0.6);
box-shadow: -3px 3px 5px -3px rgba(0,0,0,0.6);
}
#open {
border-bottom: 1px solid black;
border-right: 1px solid #fbfbfe;
text-align: center;
line-height: 50px;
background-color: #fbfbfe;
}
#closed {
border-bottom: 1px solid black;
width: 200px;
text-align: center;
line-height: 50px;
}
#pbase {
border: 1px solid black;
background-color: #fbfbfe;
position: relative;
width: 600px;
height: auto;
float: left;
margin-left: -1px;
border-radius: 0px 4px 4px 4px;
-webkit-box-shadow: -3px 3px 5px -3px rgba(0,0,0,0.6);
-moz-box-shadow: -3px 3px 5px -3px rgba(0,0,0,0.6);
box-shadow: 3px 3px 5px -3px rgba(0,0,0,0.6);
}
#closed:hover a {
display: block;
background-color: #fbfbfe;
border-right: 1px solid black;
}
#open:hover a {
display: block;
}
#detailforms {
position: relative;
margin:0 auto;
top: 10px;
width: 450px;
height: auto;
margin-bottom: 40px;
}
The height is registering as 0 because the child element is floated. CSS float takes an element out of the flow of content and wraps inline elements around it.
Your problem is here:
<div id="itemsCategListsform">
<div id="plink">
...
#plink{ float: left; }
#phase{ float: left; }
I'd recommend adding a pseudo element after the parent with clear: both set.
<div id="itemsCategListsform" class="clearfix">
<div id="plink">
...
.clearfix:after {
content: " ";
display: block;
height: 0;
clear: both;
}
See some additional solutions here.
Add display: inline-block to the css of itemsCategListsform :)
okay with a help of DACrosby was solved easily as he said that because of float left and to solve that i just add overflow: auto; tell me if i did good or there is better solution cuz this was really easy and seems to be okay everything

CSS - display: none; not working

I'm trying to develop a mobile stylesheet and in this stylesheet I want to remove a particular div.
In the HTML code of the div, I place an id called "tfl", as shown below:
<div id="tfl" style="display: block; width: 187px; height: 260px; font-family: Verdana, Arial, Helvetica, sans-serif !important; background: url(http://www.tfl.gov.uk/tfl/gettingaround/journeyplanner/banners/images/widget-panel.gif) #fff no-repeat; font-size: 11px; border: 1px solid #103994; border-radius: 4px; box-shadow: 2px 2px 3px 1px #ccc;">
<div style="display: block; padding: 30px 0 15px 0;">
<h2 style="color: rgb(36, 66, 102); text-align: center; display: block; font-size: 15px; font-family: arial; border: 0; margin-bottom: 1em; margin-top: 0; font-weight: bold !important; background: 0; padding: 0">Journey Planner</h2>
<form action="http://journeyplanner.tfl.gov.uk/user/XSLT_TRIP_REQUEST2" id="jpForm" method="post" target="tfl" style="margin: 5px 0 0 0 !important; padding: 0 !important;">
<input type="hidden" name="language" value="en" />
<!-- in language = english -->
<input type="hidden" name="execInst" value="" /><input type="hidden" name="sessionID" value="0" />
<!-- to start a new session on JP the sessionID has to be 0 -->
<input type="hidden" name="ptOptionsActive" value="-1" />
<!-- all pt options are active -->
<input type="hidden" name="place_origin" value="London" />
<!-- London is a hidden parameter for the origin location -->
<input type="hidden" name="place_destination" value="London" /><div style="padding-right: 15px; padding-left: 15px">
<input type="text" name="name_origin" style="width: 155px !important; padding: 1px" value="From" /><select style="width: 155px !important; margin: 0 !important;" name="type_origin"><option value="stop">Station or stop</option>
<option value="locator">Postcode</option>
<option value="address">Address</option>
<option value="poi">Place of interest</option>
</select>
</div>
<div style="margin-top: 10px; margin-bottom: 4px; padding-right: 15px; padding-left: 15px; padding-bottom: 15px; background: url(http://www.tfl.gov.uk/tfl/gettingaround/journeyplanner/banners/images/panel-separator.gif) no-repeat bottom;">
<input type="text" name="name_destination" style="width: 100% !important; padding: 1px" value="232 Kingsbury Road (NW9)" /><select style="width: 155px !important; margin-top: 0 !important;" name="type_destination"><option value="stop">Station or stop</option>
<option value="locator">Postcode</option>
<option value="address" selected="selected">Address</option>
<option value="poi">Place of interest</option>
</select>
</div>
<div style="background: url(http://www.tfl.gov.uk/tfl/gettingaround/journeyplanner/banners/images/panel-separator.gif) no-repeat bottom; padding-bottom: 2px; padding-top: 2px; overflow: hidden; margin-bottom: 8px">
<div style="clear: both; background: url(http://www.tfl.gov.uk/tfl-global/images/options-icons.gif) no-repeat 9.5em 0; height: 30px; padding-right: 15px; padding-left: 15px"><a style="text-decoration: none; color: #113B92; font-size: 11px; white-space: nowrap; display: inline-block; padding: 4px 0 5px 0; width: 155px" target="tfl" href="http://journeyplanner.tfl.gov.uk/user/XSLT_TRIP_REQUEST2?language=en&ptOptionsActive=1" onclick="javascript:document.getElementById('jpForm').ptOptionsActive.value='1';document.getElementById('jpForm').execInst.value='readOnly';document.getElementById('jpForm').submit(); return false">More options</a></div>
</div>
<div style="text-align: center;">
<input type="submit" title="Leave now" value="Leave now" style="border-style: none; background-color: #157DB9; display: inline-block; padding: 4px 11px; color: #fff; text-decoration: none; border-radius: 3px; border-radius: 3px; border-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,0.25); box-shadow: 0 1px 3px rgba(0,0,0,0.25); box-shadow: 0 1px 3px rgba(0,0,0,0.25); text-shadow: 0 -1px 1px rgba(0,0,0,0.25); border-bottom: 1px solid rgba(0,0,0,0.25); position: relative; cursor: pointer; font: bold 13px/1 Arial,Helvetica,sans-serif; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.4); line-height: 1;" />
</div>
</form>
</div>
</div>
This code is not mines as this an embedded code given by the TFL website.
I want to hide this div to make it more friendly for a mobile user, I did:
#tfl {
display: none;
}
This code doesn't work me though, and I even applied to the corresponding header before it and that didn't work, as shown again:
h3.tfl {
display: none;
}
What's the issue here? This code worked on another page on a mapped image. (I can't use jQuery nor JavaScript (uni assingment looking at CSS)).
This is because the inline style display:block is overriding your CSS. You'll need to either remove this inline style or use:
#tfl {
display: none !important;
}
This overrides inline styles. Note that using !important is generally not recommended unless it's a last resort.
Remove display: block; in the div #tfl style property
<div id="tfl" style="display: block; width: 187px; height: 260px;
Inline styles take priority over an external CSS file.
Try add this to your css
#tfl {
display: none !important;
}
Another trick is to use
.class {
position: absolute;
visibility:hidden;
display:none;
}
This is not likely to mess up your flow (because it takes it out of flow) and makes sure that the user can't see it, and then if display:none works later on it will be working. Keep in mind that visibility:hidden may not remove it from screen readers.
In the HTML source provided, the element #tfl has an inline style "display:block". Inline style will always override stylesheets styles…
Then, you have some options (while as you said you can't modify the html code nor using javascript):
force display:none with !important rule (not recommended)
put the div offscreen with theses rules :
#tfl {
position: absolute;
left: -9999px;
}
Best way is that you add id in your html code and then set display to none in css
example:
in html file
<input type="checkbox" name="" id="check" />
in css file
#check{ display:none; }
Check following html I removed display:block from style
<div id="tfl" style="width: 187px; height: 260px; font-family: Verdana, Arial, Helvetica, sans-serif !important; background: url(http://www.tfl.gov.uk/tfl/gettingaround/journeyplanner/banners/images/widget-panel.gif) #fff no-repeat; font-size: 11px; border: 1px solid #103994; border-radius: 4px; box-shadow: 2px 2px 3px 1px #ccc;">
<div style="display: block; padding: 30px 0 15px 0;">
<h2 style="color: rgb(36, 66, 102); text-align: center; display: block; font-size: 15px; font-family: arial; border: 0; margin-bottom: 1em; margin-top: 0; font-weight: bold !important; background: 0; padding: 0">Journey Planner</h2>
<form action="http://journeyplanner.tfl.gov.uk/user/XSLT_TRIP_REQUEST2" id="jpForm" method="post" target="tfl" style="margin: 5px 0 0 0 !important; padding: 0 !important;">
<input type="hidden" name="language" value="en" />
<!-- in language = english -->
<input type="hidden" name="execInst" value="" /><input type="hidden" name="sessionID" value="0" />
<!-- to start a new session on JP the sessionID has to be 0 -->
<input type="hidden" name="ptOptionsActive" value="-1" />
<!-- all pt options are active -->
<input type="hidden" name="place_origin" value="London" />
<!-- London is a hidden parameter for the origin location -->
<input type="hidden" name="place_destination" value="London" /><div style="padding-right: 15px; padding-left: 15px">
<input type="text" name="name_origin" style="width: 155px !important; padding: 1px" value="From" /><select style="width: 155px !important; margin: 0 !important;" name="type_origin"><option value="stop">Station or stop</option>
<option value="locator">Postcode</option>
<option value="address">Address</option>
<option value="poi">Place of interest</option>
</select>
</div>
<div style="margin-top: 10px; margin-bottom: 4px; padding-right: 15px; padding-left: 15px; padding-bottom: 15px; background: url(http://www.tfl.gov.uk/tfl/gettingaround/journeyplanner/banners/images/panel-separator.gif) no-repeat bottom;">
<input type="text" name="name_destination" style="width: 100% !important; padding: 1px" value="232 Kingsbury Road (NW9)" /><select style="width: 155px !important; margin-top: 0 !important;" name="type_destination"><option value="stop">Station or stop</option>
<option value="locator">Postcode</option>
<option value="address" selected="selected">Address</option>
<option value="poi">Place of interest</option>
</select>
</div>
<div style="background: url(http://www.tfl.gov.uk/tfl/gettingaround/journeyplanner/banners/images/panel-separator.gif) no-repeat bottom; padding-bottom: 2px; padding-top: 2px; overflow: hidden; margin-bottom: 8px">
<div style="clear: both; background: url(http://www.tfl.gov.uk/tfl-global/images/options-icons.gif) no-repeat 9.5em 0; height: 30px; padding-right: 15px; padding-left: 15px"><a style="text-decoration: none; color: #113B92; font-size: 11px; white-space: nowrap; display: inline-block; padding: 4px 0 5px 0; width: 155px" target="tfl" href="http://journeyplanner.tfl.gov.uk/user/XSLT_TRIP_REQUEST2?language=en&ptOptionsActive=1" onclick="javascript:document.getElementById('jpForm').ptOptionsActive.value='1';document.getElementById('jpForm').execInst.value='readOnly';document.getElementById('jpForm').submit(); return false">More options</a></div>
</div>
<div style="text-align: center;">
<input type="submit" title="Leave now" value="Leave now" style="border-style: none; background-color: #157DB9; display: inline-block; padding: 4px 11px; color: #fff; text-decoration: none; border-radius: 3px; border-radius: 3px; border-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,0.25); box-shadow: 0 1px 3px rgba(0,0,0,0.25); box-shadow: 0 1px 3px rgba(0,0,0,0.25); text-shadow: 0 -1px 1px rgba(0,0,0,0.25); border-bottom: 1px solid rgba(0,0,0,0.25); position: relative; cursor: pointer; font: bold 13px/1 Arial,Helvetica,sans-serif; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.4); line-height: 1;" />
</div>
</form>
</div>
</div

making text-fields aligned in a form

The following is a cut from my registration page. How can i make all the text-fields aligned ?
This form looks ugly.
Use a table with two cells
then do CSS text-align to have them aligned. For the button you can use colspan=2 and put it in the center.
I know tables are not for layout, but from my experiences they are the easiest to align fields with.
<style type="text/css">
body,input,label{`padding:0;
margin:0;`}
body > div{`background-color: #171717;
border: 1px solid #CCCCCC;
border-radius: 20px;
box-shadow: 0px 0px 10px #CCCCCC;
padding: 20px;
margin: 10px 10px;
width: 310px;
margin:30px auto;`}
input {`display: block;
width:150px;
float: left;
padding: 8px;
margin-bottom: 10px;
border: solid 1px #999;
border-radius: 5px;
font: normal 12px Arial;`}
label{`display: block;
width: 130px;
text-align: right;
float: left;
padding: 11px 10px 0 0;
font:bold 13px Verdana;
color:white;`}
button {`display: block;
margin-top:10px;
margin-left:140px;
width:50px;`}
</style>
</head>
<label>First Name</label><input name="txt" type="text" />
<label>Last Name</label><input name="txt" type="text" />
<label>Email</label><input name="txt" type="text" />
<label>Password</label><input name="txt" type="password" />
<label>Retype Password</label><input name="txt" type="password" />
<button>Send</button>
</form>
</div>
</body>