Align input[submit] with text field - css

I'm a CSS/HTML newbie and have tried to do research on this but am stumped. I've seen others with a similar problem, but their submit button and text field are only slightly misaligned. Mine is vertical but I want it horizontal.
I tried adding display: inline-block to both the text field and submit button elements, but it didn't fix the issue.
Here is the embed code for the form:
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="https://julienkozak.us14.list-manage.com/subscribe/post?
u=f46b7a895f8d332e0127067ad&id=4fbc88f22f" method="post" id="mc-
embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate"
target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-
EMAIL" placeholder="e-mail address">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none">
</div>
<div class="response" id="mce-success-response" style="display:none">
</div>
</div> <!-- real people should not fill this in and expect good things -
do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input
type="text" name="b_f46b7a895f8d332e0127067ad_4fbc88f22f" tabindex="-1"
value=""></div>
<div class="clear" ><input type="submit" value="Get Updates"
name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</form>
</div>
<!--End mc_embed_signup-->
The rest of the code you see is the CSS :
/* MAILCHIMP top form */
#mc_embed_signup {
text-align: center;
width: 300px;
}
/* Styles the header text above the inputs */
#mc_embed_signup h2 {
font-size: 18px;
margin: 0 0 20px;
color: #000000;
text-align: center;
}
/* Adds extra space around the input boxes */
#mc_embed_signup .mc-field-group {
padding: 10px 0;
}
/* Styles the input boxes */
#mc_embed_signup input {
width: 200px;
background: white;
height: 40px;
border-radius: 0px;
display: inline-block;
}
/* Styles the subscribe button */
#mc_embed_signup .button {
background-color: gray;
color: #ffffff;
margin: 0 auto;
width: 100px;
height: 40px;
display: inline-block;
}
julienkozak.com/ The form is at the top of this page.
Thank you so much for your patience with me.

Have you considered using bootstrap?
You could also use bootstrap's row functionality to dynamically set the fields of your div tag to a certain part of the page. This has the added benefit of making your page responsive to a variety of screens and monitors.

You can use flexbox on the wrapping div mc_embed_signup_scroll using display:flex. I put margin-top:10px on the button to align it with the input field.
/* MAILCHIMP top form */
#mc_embed_signup {
text-align: center;
width: 300px;
}
/* Styles the header text above the inputs */
#mc_embed_signup h2 {
font-size: 18px;
margin: 0 0 20px;
color: #000000;
text-align: center;
}
/* Adds extra space around the input boxes */
#mc_embed_signup .mc-field-group {
padding: 10px 0;
}
/* Styles the input boxes */
#mc_embed_signup input {
width: 200px;
background: white;
height: 40px;
border-radius: 0px;
}
/* Styles the subscribe button */
#mc_embed_signup .button {
background-color: gray;
color: #ffffff;
margin: 0 auto;
width: 100px;
height: 40px;
margin-top:10px;
}
#mc_embed_signup_scroll{display:flex}
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="https://julienkozak.us14.list-manage.com/subscribe/post?
u=f46b7a895f8d332e0127067ad&id=4fbc88f22f" method="post" id="mc-
embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-
EMAIL" placeholder="e-mail address">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none">
</div>
<div class="response" id="mce-success-response" style="display:none">
</div>
</div>
<!-- real people should not fill this in and expect good things -
do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_f46b7a895f8d332e0127067ad_4fbc88f22f" tabindex="-1" value=""></div>
<div class="clear"><input type="submit" value="Get Updates" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</form>
</div>

Related

Bootstrap Form Spacing

Ive been working on this form but I am now having trouble getting things to line up properly. On smaller sizes its not to big an issue, but on large screens the problem is very noticeable.
Two main issues I am finding is that I have some social links that is getting extra spacing from somewhere, though there is no padding or margins between them that I can see. Also the actual form itself is not filling in the whole space. Im not exactly sure how to fix the spacing issues here.
Anyone offer any tips?
Here is a JsFiddle of the code the code saved to SO and Jsfiddle are exact same, though it appears they are giving different results. Not sure why, though clearly I probably messed something up here.
https://jsfiddle.net/Tsukiyono/aq9Laaew/283640/
Here is another link showing things on my gitpages link:
https://tsukiyonocm.github.io/test/
edit A image of the layout I am trying to achieve.
https://imgur.com/a/al8KEMh
body {
background-color: black;
}
/** Contact
---------------------------------------------------------*/
#contactus {
color: black;
max-height: 62.5rem;
width: auto;
}
.contact-title {
font-family: futura-pt-condensed, sans-serif;
font-weight: 700;
padding: 1rem 0;
}
.contact-info {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.custom-contact {
max-height: 15rem;
}
.social {
font-weight: 700;
}
.custom-social {
max-height: 15rem;
width: auto;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.social-contact ul {
list-style: none;
display: flex;
justify-content: center;
padding: 0;
}
.social-contact ul li {
padding: 0 1rem;
}
.btn-sub {
letter-spacing: 1.5;
color: black;
background-color: #fff;
font-weight: 700;
border-radius: 0.15rem;
white-space: normal;
}
.btn-form {
width: 100%;
letter-spacing: 1.5;
color: black;
background-color: #fff;
font-weight: 700;
border-radius: 0.15rem;
}
form {
max-width: 100%;
margin: 0 .5rem;
}
.form-control {
background-color: rgb(46, 46, 46);
border: 1px solid white;
border-radius: 0.2rem;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<section id="contactus">
<div class="container">
<div class="row">
<div class="col-12 text-center">
<h1 class="display-3 contact-title">Contact Us</h1>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-6">
<div class="row contact-info d-flex flex-md-row flex-lg-column">
<div class="col-12 col-md-6 custom-contact">
<h3>- Our Office -</h3>
<address>
SOCKEROO Marketing<br>
123 Address Rd.<br>
Pittsburgh, PA<br>
15222<br>
TEL - 555.555.5555<br>
Email - sockeroomarketing#gmail.com
</address>
</div>
<div class="col-12 col-md-6 custom-social">
<p class="social">- Say Hello -</p>
<div class="social-contact">
<ul class="">
<li><i class="fab fa-inverse fa-twitter-square fa-lg"></i></li>
<li><i class="fab fa-inverse fa-facebook-square fa-lg"></i></li>
<li><i class="fab fa-inverse fa-linkedin fa-lg"></i></li>
<li><i class="fab fa-inverse fa-instagram fa-lg"></i></li>
</ul>
</div>
<button class="btn btn-sub">Subscribe to Our Newsletter</button>
</div>
</div>
</div>
<div class="col-12 col-lg-6 m-0 p-0">
<form action="">
<div class="form-group">
<input type="text" class="form-control" placeholder="Name">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Company or Organization">
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Email Address">
</div>
<div class="form-group">
<input type="tel" class="form-control" placeholder="Phone Number">
</div>
<div class="form-group">
<textarea name="comment" class="form-control" placeholder="Tell us a bit about your project, timeline, and budget"></textarea>
</div>
<button class="btn btn-form">Submit</button>
</form>
</div>
</div>
</div>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
In regards to the inconsistency between JSFiddle and Github pages, I believe the problem lies in the way bootstrap implements their col-md-6 class. Namely, the flex-basis property.
For reference, this is what I see their class to be, based on the element inspector in chrome:
#media (min-width: 768px)
.col-md-6 {
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
(A little context: flex is shorthand for defining flex-grow, flex-shrink, and flex-basis, in that order. You can find that info in this article on CSS-Tricks: here and a little more detail on flex basis just above it, here).
As you can see, they're setting flex basis to 50%. Once I set both the jsfiddle and gitpages' flex property to flex: 0 0 auto, the spacing was consistent on both of those pages, leading me to wonder if flex-basis is calculating 50% to be one value in the JSFiddle and another value in your Github pages. As for a solution, what you can do is create a custom class, let's say .cust-col-md-6, and copy the ruleset defined by bootstrap, but change the flex-basis of the property to auto:
#media (min-width: 768px)
.cust-col-md-6 {
-ms-flex: 0 0 auto;
flex: 0 0 auto;
max-width: 50%;
}
Then from here you can set that as your class instead of using .col-md-6:
<div class="col-12 cust-col-md-6 custom-social">

How do you apply z-index on parallax image

I am trying to overlap my survey form over a parallax image (creating using MateralizeCss) using Z-index. However, my form still remains under the image. Please help! *Cant provide my codes as it is in xslt. Any simple example will be appreciated.
This is the html code
<div class="parallax-container">
<div class="parallax">
<img src="http://materializecss.com/images/parallax1.jpg" />
</div>
</div>
<div style="width:50%;margin: 0 auto ;z-index:1000;background-color:white;padding:2.5%; box-shadow: 0px 4px 5px gray,
-5px 4px 7px gray, 5px 4px 7px gray;margin-bottom:5%;position:absolute">
<div style="font-size:250%;font-weight:bold">In Store Hub Trooper Feedback Form</div>
<div style="font-size:150%;">Q number</div>
<div>
<input type="number" required="required" />
</div>
<div style="font-size:150%;">Dateeeeeeeeeeeeee</div>
<div id="input">
<input type="date" class="datepicker" required="required">
</input>
<span>
</span>
</div>
Both the form and the image will need a position property.
HTML
<form id="myform" class="overlap">
<button id="button" name="button">A button</button>
<br/>
<input type="submit" value="submit">
</form>
<div class="box">
Thing overlapping with form
</div>
CSS
.overlap {
position: relative;
margin: 0 auto;
background-color: #ccc;
padding: 3em;
width: 50%;
}
.box {
position: absolute;
top: 6em;
right: 20%;
background-color: #666;
color: #fff;
padding: 3em;
width: 25%;
}
I made you a CodePen:
See the Pen Overlapping things with z-index by Yvonne Aburrow (#vogelbeere) on CodePen.
EDIT: I added my answer before you updated the question with your code.

How to make search bar responsive using CSS

I have a search bar at my website page http://positivelynuts.co.uk/blog/
It shows only for half width on mobile devices and looks small. How can I make it responsive using CSS so that it takes the fullwidth on mobiles and comes above the pagination page links ?
<div class="blogpage_search" style="width: 50%; float:left;">
<form role="search" method="get" id="searchform" class="searchform" action="http://positivelynuts.co.uk">
<div class="search-form">
<input type="text" value="" name="s" id="s">
<input type="submit" id="searchsubmit" value="Search">
</div>
</form>
</div>
first take the style="width: 50%; float:left;" element out and add this to your css file:
.blogpage_search {
width: 50%;
float: left;
margin-top: 7px;
}
#media screen and (max-width: 600px) {
.blogpage_search {
float: none;
width: 100%;
margin: 10px auto;
}
}
That should do the trick! Thank you!
use width:100%;
<div class="blogpage_search" style="width: 100%; float:left;">

Using column divs with the line-height attribute to align textboxes with their labels

I have aligned textboxes with their labels using the line-height method proposed here. I didn't simply use the width attribute because I wanted it to dynamically adjust if the label text changed. To get Firefox (haven't tried other browsers) to apply the line height to the column with the inputs, I had to use this hack (note the <div class="hack">):
HTML
<div class="textbox-column label">
<div>User Name:</div>
<div>Password:</div>
</div>
<div class="textbox-column input">
<div><div class="hack">#</div><input type="textbox" name="username" /></div>
<div><div class="hack">#</div><input type="password" name="password" /></div>
</div>
<div class="clear"></div>
CSS
div.clear {
clear: both;
}
.textbox-column {
line-height:1.6em;
}
.textbox-column.label {
float: left;
margin-right:1em;
}
.textbox-column.input {
float: right;
}
.textbox-column .hack {
display: inline;
width: 1em;
margin-right: -1em;
}
Can any one suggest a cleaner solution?
Here is a live demo of this code: http://jsfiddle.net/fbe7P/
CSS works best when things are grouped together, so I would group the controls into rows.
Also, the plus side of this method is that it degrades well for small screen sizes.
HTML:
<div class="row">
<label for="username">Username:</label>
<input type="text" id="username" />
</div>
<div class="row">
<label for="password">Password:</label>
<input type="password" id="password" />
</div>​
CSS:
.row {
overflow: auto;
}
.row label {
float: left;
min-width: 100px;
}
.row input {
float: right;
}
Demo: http://jsfiddle.net/ezp9H/2/

css - have two inline inputs take up remaining space

I have the following html:
<div id="holder">
<span>Search for</span>
<input id="srchfor" />
<span>near</span>
<input id="srchin" />
<span>submit</span>
</div>
The containing div is fixed width. The width of the 3 spans will depend on font size. Is it possible to make the two inputs take a width so that they are both equally sized, and they consume all the remaining space in holder? Or does this require using javascript?
Edit: My aim is to have the 5 elements all on one line, rather than split over several lines.
This is an old post but I came across it and figured I would answer it for the next person. Here is a CSS/HTML snippet that should resolve this issue. It is kind of like a HTML5 flexbox but without HTML5 or a flexbox. You can add width to whatever 2 sections needed and the third will fill the remaining void.
<style type="text/css">
.form-group {
border: 1px solid black;
margin-bottom: 20px;
padding: 10px;
width: 75%;
}
.a {
float: right;
margin-left: 10px;
width: 30%;
}
.a input {
width: 100%;
}
.b {
float: left;
margin-right: 10px;
width: 33%;
}
.b input {
width: 100%;
}
.c {
display: block;
overflow: hidden;
}
.c input {
width: 100%;
}
</style>
<div id="wrapper">
<div class="form-group">
<span class="a">
<label>Thing 1</label><br />
<input type="text" />
</span>
<span class="b">
<label>Thing 2</label><br />
<input type="text" />
</span>
<span class="c">
<label>Thing 3</label><br>
<input type="text" />
</span>
</div>
<div class="form-group">
<div class="a">
<label>Thing 1</label><br />
<input type="text" />
</div>
<div class="b">
<label>Thing 2</label><br />
<input type="text" />
</div>
<div class="c">
<label>Thing 3</label><br>
<input type="text" />
</div>
</div>
</div>
Well, you could change the display type from display: inline to display: block to make them fill space. But I don't know if the inline is an requirement.
You have to choose a fixed width for the span elements, and use the display:inline-block property like in this example.

Resources