How do I get this section with the form to center. The form field and button aren't centering - html

I need the text to center in the middle of the section and the field and button to align under that text (with the field and button remaining side by side.) Everything is good - the field and button are currently beside each other the way it's supposed to be, but just it's all not centering properly. The text is centered but the form field and button are messed up. I have attached an image. I'm using HTML5, CSS3 and bootstrap.
<section class="more-products">
<div class="container">
<div class="row">
<div class=" col-lg-8 col-md-4 col-sm-4 prod-form">
<p class="par-headform"> TEXT</p>
<p class="para-form">
text about products
</p>
<p class="para-blue">
Sign up for the newsletter Stay informed
</p>
<form class="subscribe_group wow fadeInUp row col-m-12">
<div class=" col-md-6 col-sm-6 col-xs-5 ">
<input class="form-control subscribe_mail" type="email" placeholder="email">
</div>
<div class="col-md-5 col-sm-6 col-xs-5 " >
<input class="btn-form" type="submit" value="Subscribe">
</div>
</form>
</div>
</div>
</div>
</section>
CSS
.more-products {
padding: 60px 0;
background: #FCFCFC;
text-align: center;
}
.more-products .block {
position: relative;
z-index: 99;
}
.more-products .par-headform .block {
padding: 20px 15px;
margin-top: 0;
color: #666;
}
.prod-form .btn-form {
border: 1px solid #00bfff;
background-color: #fff;
color: #00bfff;
padding: 3% 14%;
font-weight: 500;
text-decoration: none;
border-radius: 200px;
transition: background-color 0.2s, border 0.2s, color 0.2s;
border: 1px solid #00bfff;
background-color: #fff;
letter-spacing: .8px;
font-size: 120%;
display: inline-block;
}
.prod-form .btn-form: Hover{
color: #00bfff;
padding: 3% 14%;
font-weight: 500;
text-decoration: none;
border-radius: 200px;
transition: background-color 0.2s, border 0.2s, color 0.2s;
border: 1px solid #00bfff;
background-color: #fff;
letter-spacing: .8px;
font-size: 120%;
display: inline-block;
}
.par-headform {
font-size: 250%;
line-height: 35px;
}
.form-control {
max-width: auto;
margin: 1px;
}

Try this:
<form class="subscribe_group wow fadeInUp row col-m-12">
<div class="col-lg-8 col-md-4 col-sm-4 center1">
<input class="form-control subscribe_mail" type="email" placeholder="email">
<input class="btn-form" type="submit" value="Subscribe">
</div>
</form>
I removed the DIV tags around the two input elements (to have them in one wrapper), gave the parent DIV the same classes as the DIV for the texts above it and added an additional class center1, which you have to put into your CSS like
.center1 {
text-align: center;
}
The input elements need to be defined as inline-blocks, if they aren't already:
.subscribe_mail, .btn-form {
display: inline-block;
}
Since you don't have a fiddle or codepen, I can't try it, but it should work - maybe the classes in the DIV around the input tags need to be different, that depends on the rest of your code.

use the following css for form and div's inside the form.
form {
width: auto;
display: inline-table;
}
form > div {
margin: 0 auto;
float: left;
}
and change subscribe padding to px instead of % like below example
.prod-form .btn-form {
padding: 3px 6px;
}
UPDATE
use the following css to the section
section {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
}
check the jsfiddle https://jsfiddle.net/s45wgw1h/1/

Related

How can I configure my css so that a span's height matches the adjacent input's height (Hubspot)?

Here's the result that I'm trying to fix:
As you can see, the span with the percent symbol is stretching to fit the margin that is on the input. How can I prevent this? I've tried multiple css attributes but can't seem to break the span out of taking on the input's excess margin.
This is created using Hubspot CMS and I've had to try and recreate the bootstrap styling on my normal site.
Here is the markup:
<div class="row">
<div class="col-sm-6">
<label for="monthly-traffic" class="control-label">Monthly traffic (unique visitors)</label>
<input class="form-control" type="number" name="monthly-traffic" id="monthly-traffic" class="form-control" placeholder="monthly traffic">
</div>
<div class="col-sm-6">
<label for="percent-us" class="control-label">Percent of traffic from US</label>
<div class="input-group">
<input id="percent-us-addon" class="form-control" type="number" name="percent-us" placeholder="US traffic percentage" aria-describedby="percent-us-addon">
<span class="input-group-addon">%</span>
</div>
</div>
</div>
and the css for:
col-sm-6: {
width: 50%;
float: left;
position: relative;
min-height: 1px;
padding-left: 15px;
padding-right: 15px;
}
input-group: {
border-left: 0;
border-bottom-left-radius: 0;
border-top-left-radius: 0;
position: relative;
display: table;
border-collapse: separate;
}
form-control: {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
vertical-align: middle;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
and
input-group-addon:{
padding: 6px 12px;
font-size: 14px;
font-weight: 400;
line-height: 1;
color: #555;
text-align: center;
background-color: #e2e2e2;
border: 1px solid #ccc;
border-radius: 4px;
width: 1%;
white-space: nowrap;
vertical-align: middle;
display: table-cell;
}
Your markup is missing the .input-group wrapper and the appropriate addon classes (.input-group-append and .input-group-text).
With this markup, you should not need any custom CSS at all:
<label for="percent-us" class="control-label">Percent of traffic from US</label>
<div class="input-group">
<input id="percent-us-addon" class="form-control" type="number" name="percent-us" placeholder="US traffic percentage" aria-describedby="percent-us-addon">
<div class="input-group-append">
<span class="input-group-text">%</span>
</div>
</div>
Full codepen # https://codepen.io/cfxd/pen/ywbjxZ

How to select two different input type text that is in a div?

I have two different inputs of type text and I'd like to apply different styles to each of them. How would I go about doing that?
div input[type=text] {
background-color: #212121;
border: none;
color: white;
padding: 1px 5px;
text-align: right;
text-decoration: none;
display: inline-block;
font-size: 10px;
width: 86px;
height: 35px;
}
.contact-field {
width: 33.33%;
display: inline-block;
vertical-align: top;
}
.contact-field input {
width: 90%;
padding: 10px;
border: 3px solid #dedede;
outline: none;
margin-bottom: 10px;
transition: all .325s;
}
<div class="row">
<div class="column">
<input type="text" name="MAR 7" value="MAR 7">
</div>
<div class="column">
<div class="caption">
<h5>Ziggo Dome</h5>
<h6>NIEUW-AMSTERDAM, NETHERLANDS</h6>
</div>
</div>
<div class="main-container">
<section class="contact-container">
<form method="GET" action="#">
<div class="contact-field">
<input type="text" name="full-name" placeholder="Email Address" required/>
</div>
I am clearly new to this. I hope that you can help me.
In the css, to target the first input you'd do something like this - .row .column input[type="text"]
And the second one like this - .main-container .contact-container form contact-field input[type="text"]
This'll allow you to apply different css styles to your each of your inputs, without them crossing over.

online div not side by side

I have this code below. I have one container div with 2 inner div. I want the two inner divs to be side by side so I used in-line block on the two divs. Also I want the two divs to be start on top. In the demo below they are stuck on top and I dont know why while in my own project they are side by side but first div starts on top while second div does not start on top.
What is the best css style to make the 2 div in a container start on top while it is side by side?
What is the best way to make two div side by side?
.homissync {
display: block;
height: 100%;
}
.homissync>div {
padding: 27px;
margin: 3px;
display: inline-block;
}
#homissyncbuttons {
height: 100vh;
width: 20%;
margin: 3px;
}
#homissynclist {
height: 100vh;
margin: 3px;
width: 68%;
}
#homissyncbuttons .libuttons {
width: 100% !important;
background-color: #ff0000;
}
.vBorder {
border: solid 1px #ddd;
}
button, input[type=submit] {
padding: 8px 20px;
color: #fff;
text-shadow: 0 0 2px rgba(0,0,0,0.35);
background-color: orange;
font-size: 0.9rem;
font-weight: bold;
border-radius: 3px;
border: 0;
outline: none !important;
margin: 3px 0;
cursor: pointer;
transition: background 1s ease-in-out;
}
<div class=" homissync">
<div id="homissyncbuttons" class=" vBorder">
<ul>
<li>
<button class="libuttons">UACS</button>
</li>
<li>
<button class="libuttons">Medicine</button>
</li>
<li>
<button class="libuttons">Non-Drugs</button>
</li>
<li>
<button class="libuttons">Miscellaneous</button>
</li>
</ul>
</div>
<div id="homissynclist" class=" vBorder">
<button class="listbuttons" id="new_uacs_entry">New UACS Entry</button>
<button class="listbuttons" id="update_uacs_entry">Update UACS Entry</button>
<div id="homissynclistresult" class=" vPadding vBorder">
</div>
</div>
</div>
Please try this code instead of the display:inline-block; and just add float:left.
.homissync>div {
display: block;
float: left;
}
you can use float: left; instead of display: inline-block;
.homissync {
display: block;
height: 100%;
}
.homissync>div {
padding: 27px;
margin: 3px;
float:left;
}
#homissyncbuttons {
height: 100vh;
width: 20%;
margin: 3px;
}
#homissynclist {
height: 100vh;
margin: 3px;
width: 65%;
}
#homissyncbuttons .libuttons {
width: 100% !important;
background-color: #ff0000;
}
.vBorder {
border: solid 1px #ddd;
}
button, input[type=submit] {
padding: 8px 20px;
color: #fff;
text-shadow: 0 0 2px rgba(0,0,0,0.35);
background-color: orange;
font-size: 0.9rem;
font-weight: bold;
border-radius: 3px;
border: 0;
outline: none !important;
margin: 3px 0;
cursor: pointer;
transition: background 1s ease-in-out;
}
<div class=" homissync">
<div id="homissyncbuttons" class=" vBorder">
<ul>
<li>
<button class="libuttons">UACS</button>
</li>
<li>
<button class="libuttons">Medicine</button>
</li>
<li>
<button class="libuttons">Non-Drugs</button>
</li>
<li>
<button class="libuttons">Miscellaneous</button>
</li>
</ul>
</div>
<div id="homissynclist" class=" vBorder">
<button class="listbuttons" id="new_uacs_entry">New UACS Entry</button>
<button class="listbuttons" id="update_uacs_entry">Update UACS Entry</button>
<div id="homissynclistresult" class=" vPadding vBorder">
</div>
</div>
</div>
display:inline-block have default white space, you need to remove the white space. otherwise you need to relace the display-inline-block with float:left , there is so many options to remove the white space please check the reference link below
Why is there an unexplainable gap between these inline-block div elements?

How to put a border-radius on a specific corner of a button

I have a modal that looks like this
As you can see, the modal has border-radius but the buttons at the footer dont. I want to put a border-radius at the bottom left of the purple button and a border-radius at the bottom right of the gray button. Ive tried border-bottom-left-radius and border-bottom-right-radius but it didnt work. Here`s my codes
Modal:
<!--Notifier Modal-->
<div id="notifier-modal" class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<div class="confirm-purchase-label">
Only {{size}} out of {{totalsize}} transactions have been loaded <br>
<h5>The complete list of transactions will be sent to your email after the process.</h5>
</div>
</div>
</div>
</div>
<div class="modal-footer g-nopadding">
<div class="col-md-6 g-nopadding">
<button type="button" class="btn btn-purple btn-block col-md-6" ng-click="proceedAction();">PROCEED</button>
</div>
<div class="col-md-6 g-nopadding">
<button type="button" class="btn btn-gray btn-block col-md-6" data-dismiss="modal">CANCEL</button>
</div>
</div>
</div>
</div>
CSS:
#notifier-modal .btn,
{
border: none!important;
border-radius: 0px!important;
font-family: 'AvenirMedium';
height: 50px!important;
}
#notifier-modal .modal-md{
width: 500px;
}
.modal-footer {
padding: 15px;
text-align: right;
border-top: 1px solid #e5e5e5;
}
.modal-content{
background:#f0f0f0;
box-shadow:0px 0px 30px 0px rgba(101,101,101,0.50);
border: none;
}
.btn-gray {
color: #797979!important;
background:#e0e0e0!important;
font-size:14px!important;
border: none!important;
}
.btn-purple {
color: #f0f0f0!important;
background-color: #9c82cd!important;
font-size:14px!important;
border: none!important;
}
.modal-footer{
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
overflow: hidden;
}
overflow: hidden solves it.
You can just apply a border-radius to all side of the modal that already has the top left/right border-radius, and assuming the buttons are at the bottom corners of that element, if you also add overflow: hidden to the modal with the border-radius, it will clip the corners of the buttons.
body {
background: #aaa;
text-align: center;
}
div {
background: #fff;
border-radius: 1em;
padding: 1em;
display: inline-block;
width: 200px;
height: 100px;
position: relative;
overflow: hidden;
}
button {
position: absolute;
bottom: 0;
padding: 0;
margin: 0;
width: 50%;
left: 0;
padding: .5em 0;
background: #09c;
color: white;
border: 0;
}
button:last-child {
left: auto;
right: 0;
border-left: 1px solid white;
}
<div>
<button>button</button>
<button>button</button>
</div>
To put a border-radius at the bottom left of the purple button You can use below CSS
.btn-purple {
color: #f0f0f0!important;
background-color: #9c82cd!important;
font-size: 14px!important;
border: none!important;
border-radius: 0 0 0 20px; /*20px is example you can use how much radius you want*/
}
To put a border-radius at the bottom right of the gray button. You can use below CSS
.btn-gray {
color: #797979!important;
background: #e0e0e0!important;
font-size: 14px!important;
border: none!important;
border-radius: 0 0 20px 0;
}
Add the following CSS to your buttons and adjust for each accordingly
-moz-border-radius-topleft: 0px;
-moz-border-radius-topright:0px;
-moz-border-radius-bottomleft:5px;
-moz-border-radius-bottomright:5px;
-webkit-border-top-left-radius:0px;
-webkit-border-top-right-radius:0px;
-webkit-border-bottom-left-radius:5px;
-webkit-border-bottom-right-radius:5px;
border-top-left-radius:0px;
border-top-right-radius:0px;
border-bottom-left-radius:5px;
border-bottom-right-radius:5px;
The issue is simply a word-ordering one :)
Instead of border-radius-bottom-left and border-radius-bottom-right, the attributes you're looking for are border-bottom-left-radius and border-bottom-right-radius:
.modal-footer {
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
Hope this helps! :)
As discussed you have border radius set to zero important in css
#notifier-modal .btn,
{
border: none!important;
border-radius: 0px!important;
font-family: 'AvenirMedium';
height: 50px!important;
}
Try commenting it out and then adding in the bottom ones.
There are many resources online but the best one i have found is
Border radius
it lets you set border radius seperatly or all at once. It also give you the CSS to use.
Cheers

CSS: How to make custom file upload button take full width (button works)

I am new to CSS and hope someone here can help me with this.
I am trying to apply a simple custom style to a file upload button (as part of an HTML form) to make it look similar to other buttons on my page and to get a similar look cross-browser.
So far I have the following which works as intended.
My only problem now is that I would like the button to take the full width of its parent div (in my case this will span across 9/12 ('col-9') of the page).
I tried adding width: 100%; to the CSS but then the button doesn't work anymore.
My HTML:
<div class="col-3 frmCaption">Attachments:</div>
<div class="col-9">
<div class="customUpload btnUpload btnM">
<span>Upload files</span>
<input type="file" class="upload" />
</div>
</div>
My CSS:
.btnDefault, .btnUpload {
background-color: #FFFFFF;
border: 1px solid #CCCCCC;
color: #333333;
cursor: pointer;
font-weight: 400;
display: inline-block;
padding: 6px 12px;
text-align: center;
text-decoration: none;
vertical-align: middle;
}
.btnDefault:focus, .btnDefault:hover, .btnUpload:focus, .btnUpload:hover {
background-color: #E6E6E6;
}
.btnM {
border-radius: 4px;
font-size: 14px;
padding: 6px 12px;
}
.customUpload {
overflow: hidden;
position: relative;
}
.customUpload input.upload {
cursor: pointer;
margin: 0;
opacity: 0;
filter: alpha(opacity=0);
padding: 0;
position: absolute;
right: 0;
top: 0;
}
To style input elements, you need to actually style its label element.
From MDN,
The HTML Label Element () represents a caption for an item in a user interface. It can be associated with a control either by placing the control element inside the element, or by using the for attribute. Such a control is called the labeled control of the label element.
So, whenever you click a label, the attached input gets triggered.
So, just wrap the input element in a label instead of a div and stretch as much as you want. That will fix your issue.
.btnDefault,
.btnUpload {
background-color: #FFFFFF;
border: 1px solid #CCCCCC;
color: #333333;
cursor: pointer;
font-weight: 400;
display: inline-block;
padding: 6px 12px;
text-align: center;
text-decoration: none;
vertical-align: middle;
}
.btnDefault:focus,
.btnDefault:hover,
.btnUpload:focus,
.btnUpload:hover {
background-color: #E6E6E6;
}
.btnM {
border-radius: 4px;
font-size: 14px;
padding: 6px 12px;
}
.customUpload {
overflow: hidden;
position: relative;
display: block;
}
.customUpload input.upload {
cursor: pointer;
margin: 0;
opacity: 0;
filter: alpha(opacity=0);
padding: 0;
position: absolute;
right: 0;
top: 0;
}
<div class="col-3 frmCaption">Attachments:</div>
<div class="col-9">
<label class="customUpload btnUpload btnM"> <span>Upload files</span>
<input type="file" class="upload" />
</label>
</div>
Working Fiddle
You need to apply the width property to the containing <div> as well. Once the div has the full size, then only the button inside can have the full width.
For simplicity i have made change to html, you can move it to appropriate classes.
<div class="col-3 frmCaption">Attachments:</div>
<div class="col-9">
<div class="customUpload btnUpload btnM" style="width:100%;">
<span>Upload files</span>
<input type="file" class="upload" style="width:100%;"/>
</div>
</div>
JS Fiddle
Or you can use this CSS andadd it both to your div and file upload,
.fullwidth
{
width : 100%;
}
<div class="col-3 frmCaption">Attachments:</div>
<div class="col-9">
<div class="customUpload btnUpload btnM fullwidth">
<span>Upload files</span>
<input type="file" class="upload fullwidth"/>
</div>
</div>
Make the button take 12 cols (as you use a 12 col system) , as that is the max number of cils available, in that way the elemts will take up the size of the div that it is contained in