Html text not centered - html

The issue is documented in this JSFiddle:
http://jsfiddle.net/sawaira/j62309fx/39/
<div style="height:700px; width:1500px;">
<div id="loading-image">Stabilizing iteration (90% done)</div>
<div id="kl" style="position:absolute;height:700px; width:1200px;float:left;border: 2px solid
#0094ff;overflow:auto">
</div>
<div style="height:100%; width:300px;float:right;border: 2px solid #0094ff;border-radius:5px">
<div style="height:100%; width:100%;">
<table style="width:100%;">
<tr>
<td colspan="4">
<div class="containerChart2">
<div class="headerChartControl">
<span>My Team(s):</span>
</div>
<div id="filterHolder1" class="listControl">
<form id="formUserListObject">
<input type="checkbox" name="userSelection" id="{{id}}"
onchange="checkBoxSelected(id,false)" class="css-checkbox"/>
<label for="{{id}}" class="css-label">
{{userName}}
</label>
</form>
</div>
</div>
</td>
</tr>
<tr>
<td colspan="4">
<div class="containerChart2">
<div class="headerChartControl">
<span>Find Other Team(s):</span>
</div>
<div class="contentSearch">
<!-- This is the HTML element that will be used to render the KeyLines
component -->
<form id="formSearch" class="formSearch">
<input type="search" id="searchBox" />
</form>
<!--label id="headervalue2">Search Results:</label-->
<div id="filterHolder2" class="listControl"></div>
</div>
</div>
</td>
</tr>
<td colspan="4">
<div class="headerChartControl">
<input type="button" onclick="document.getElementById('loading-
image').style.display ='block'" value="Show"/>
<input type="button" onclick="document.getElementById('loading-image').style.display ='none'" value="Hide"/>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
#formUserListObject {
font-size: x-small;
}
#tab0 {
top: 50px;
}
#page {
display: none;
}
#loading-image {
position:absolute;
top: 50%;
left:50%;
z-index:1;
font-size: 20px;
color: red;
}
.overallDiv {
height: 100%;
width: 100%;
background-color: #ff6a00;
}
.myDiv {
height: 100%;
width: 100%;
background-color: #b6ff00;
}
.formClass {
}
.listControl {
padding-top: 5px;
padding-right: 15px;
padding-bottom: 5px;
padding-left: 15px;
border: 2px solid #0094ff;
height: 100px;
overflow-y: scroll;
}
.paddingControl {
padding-top: 5px;
padding-right: 10px;
padding-bottom: 5px;
padding-left: 10px;
}
.slider {
padding-top: 5px;
padding-right: 15px;
padding-bottom: 5px;
padding-left: 15px;
background-color: #00ff90;
}
input[type=checkbox].css-checkbox {
position:absolute;
z-index: -1000;
left: -1000px;
overflow: hidden;
clip: rect(0 0 0 0);
height: 1px;
width: 1px;
padding: 0;
margin: -1px;
border: 0;
}
input[type=checkbox].css-checkbox + label.css-label {
padding-left: 20px;
height: 15px;
display: inline-block;
line-height: 15px;
background-repeat: no-repeat;
background-position: 0 0;
font-family: Arial;
font-size: 10px;
cursor: pointer;
}
input[type=checkbox].css-checkbox:checked + label.css-label {
background-position: 0 -15px;
}
label.css-label {
background-image: url
(http://csscheckbox.com/checkboxes/u/csscheckbox_845137eccd6f9ac2355055adf283a248.png);
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
input[type=checkbox].css-checkbox + label.css-labelMinus {
padding-left: 20px;
height: 15px;
display: inline-block;
line-height: 15px;
background-repeat: no-repeat;
background-position: 0 -15px;
font-family: Arial;
font-size: 10px;
cursor: pointer;
}
input[type=checkbox].css-checkbox:checked + label.css-labelMinus {
background-position: 0 -15px;
}
label.css-labelMinus {
background-image: url
(http://csscheckbox.com/checkboxes/u/csscheckbox_845137eccd6f9ac2355055adf283a248.png);
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.headerChartControl {
background-color: #9ed1f6;
cursor: pointer;
font-family: Arial;
font-size: 12px;
font-weight: bold;
width: 100%;
}
.contentSearch {
width: 100%;
}
.listControl {
border: 1px solid #0094ff;
height: 100px;
overflow-y: scroll;
}
.searchText {
font-family: Arial;
font-size: 10px;
}
.formSearch {
width: 100%;
display: inline-block;
padding-bottom: 2px;
}
input[type="search"] {
background: white url
(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAMAAABhq6zVAAAAIVBMVEW/v7+/v78AAAC/v7+/v7+/v7+/v7+/v7+/v
7+/v7+/v79QUkolAAAAC3RSTlOLYAAJeoMjRhpOcbsbtd4AAABJSURBVHjaVc1JDsAgDATB9uAF8v8Hx0QcSN9KssZI5eClDj18PRsFlmlQDcfUG
d6A3EgYP1xncQ+sa5qYOk9jRQt1Y0izhU5bL2o2AW3ZQKeJAAAAAElFTkSuQmCC) 10px 6px no-repeat;
height: 20px;
border: 1px solid #0094ff;
width: 100%;
}
input[type="search"] {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-appearance: textfield;
}
input[type="search"]::-webkit-search-cancel-button {
-webkit-appearance: searchfield-cancel-button;
}
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: searchfield-decoration;
}
I have added 2 buttons to show and hide the Loading text. I want the "Loading Text" itself to always be positioned in the middle of the "kl" div, even on scroll/resizing of window.
Even with top/left = 50% and position=absolute, the text is not centered (mainly on resizing). What do I need to change to get it centered properly.

Check this :http://jsfiddle.net/8b6zk90c
just i added position:relative to outer and inner div to position:fixed

Hi You can add two properties to achieve text in middle of your kl DIV
text-align: center;
line-height: 700px;
It will do the magic

Related

Change font-size does not influence whole header

I am trying to do sticky header on my existing page an I have all margins in rem but when I set up font-size for main header which contains all header content is influenced just ul list part and other margins are the same. Can you please advice me what is problem?
I want to make header more slim when I scroll down.
JQuery code:
$(window).scroll(function() {
if ($(this).scrollTop() > 10) {
$('.mheader').addClass("sticky_header");
}
else {
$('.mheader ').removeClass("sticky_header");
}
})
CSS header code:
.mheader {
width: 100%;
height: 4.75rem;
box-shadow: 1px 1px 1px #ccc;
background: #eee;
}
.sticky_header {
position: fixed;
z-index: 999;
font-size: 0.8rem !important;
transition: all 1s ease;
}
.mheader__logo img {
position: relative;
width: 10.1%;
float: left;
height: 2.3rem;
margin: 1.225rem 0.9375rem;
}
.mheader__nav {
float: left;
width: 55%;
margin: 0.9375rem 0 0.9375rem 0;
}
.mheader__nav-mobilemenu {
display: none;
}
.mheader__nav-list {
width: 100%;
margin: 0;
}
.mheader__nav-list li {
float: left;
width: 18%;
margin: 0 20px;
padding-left: 10px;
border-left: 1px solid #ccc;
list-style-type: none;
text-transform: uppercase;
font-weight: bold;
font-family: 'Roboto Condensed', sans-serif;
}
.mheader__nav-list a {
display: block;
text-decoration: none;
color: black;
}
.mheader__nav-list a:hover {
color: black;
border-bottom: 2px solid #111;
}
.mheader__search {
position: relative;
float: right;
width: 25%;
margin: 1.225rem 1.875rem 1.225rem 0;
}
.mheader__search input {
width: 100%;
height: 2.3rem;
border: 1px solid #aaa;
border-radius: 0.25rem;
font-size: 1.0625rem;
padding-left: 0.25rem;
}
.mheader__search-button {
position: absolute;
right: 0px;
top: 4px;
}
.mheader__search button {
float: right;
border: none;
background: none;
font-size: 1.125rem;
cursor: pointer;
}
HTML code
<header class="mheader">
<div class="mheader__logo">
<img src="/assets/img/logo.png" alt="">
</div>
<div class="mheader__nav">
<a href="#menu" class="mheader__nav-mobilemenu">
<img src="/assets/img/mob-menu.svg" alt="">
</a>
<!--<i class="fa fa-bars"></i>-->
<ul class="mheader__nav-list group">
<!-- use absolute path -> do not change path with subfolder-->
<li>Job </br>ToDo</li>
<li>Activity </br>Home</li>
<li></br>BLOG</li>
<li>Sign </br>Out</li>
</ul>
</div>
<div class="mheader__search">
<input type="text" placeholder="Search...">
<div class="mheader__search-button">
<button type="submit"><i class="fa fa-search"></i></button>
</div>
</div>
</header>
Thank you
Make sure you use EM instead of REM if you want to make it relative to some parent. So all the REM sizes are based on the <html> tag.
If you do em,
$(window).scroll(function() {
if ($(this).scrollTop() > 10) {
$('.mheader').addClass("sticky_header");
}
else {
$('.mheader ').removeClass("sticky_header");
}
})
body{
height:4000px;
}
.mheader {
width: 100%;
height: 4.75rem;
box-shadow: 1px 1px 1px #ccc;
background: #eee;
}
.sticky_header {
position: fixed;
z-index: 999;
font-size: 0.8em !important;
transition: all 1s ease;
}
.mheader__logo img {
position: relative;
width: 10.1%;
float: left;
height: 2.3em;
margin: 1.225em 0.9375em;
}
.mheader__nav {
float: left;
width: 55%;
margin: 0.9375em 0 0.9375em 0;
}
.mheader__nav-mobilemenu {
display: none;
}
.mheader__nav-list {
width: 100%;
margin: 0;
}
.mheader__nav-list li {
float: left;
width: 18%;
margin: 0 20px;
padding-left: 10px;
border-left: 1px solid #ccc;
list-style-type: none;
text-transform: uppercase;
font-weight: bold;
font-family: 'Roboto Condensed', sans-serif;
}
.mheader__nav-list a {
display: block;
text-decoration: none;
color: black;
}
.mheader__nav-list a:hover {
color: black;
border-bottom: 2px solid #111;
}
.mheader__search {
position: relative;
float: right;
width: 25%;
margin: 1.225em 1.875em 1.225em 0;
}
.mheader__search input {
width: 100%;
height: 2.3em;
border: 1px solid #aaa;
border-radius: 0.25em;
font-size: 1.0625em;
padding-left: 0.25em;
}
.mheader__search-button {
position: absolute;
right: 0px;
top: 4px;
}
.mheader__search button {
float: right;
border: none;
background: none;
font-size: 1.125em;
cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<header class="mheader">
<div class="mheader__logo">
<img src="/assets/img/logo.png" alt="">
</div>
<div class="mheader__nav">
<a href="#menu" class="mheader__nav-mobilemenu">
<img src="/assets/img/mob-menu.svg" alt="">
</a>
<!--<i class="fa fa-bars"></i>-->
<ul class="mheader__nav-list group">
<!-- use absolute path -> do not change path with subfolder-->
<li>Job </br>ToDo</li>
<li>Activity </br>Home</li>
<li></br>BLOG</li>
<li>Sign </br>Out</li>
</ul>
</div>
<div class="mheader__search">
<input type="text" placeholder="Search...">
<div class="mheader__search-button">
<button type="submit"><i class="fa fa-search"></i></button>
</div>
</div>
</header>

how to align a text beside form at CSS and HTML

I have a problem: I want to align an interactive text which is already in the left of a slider. So, I just want to align a login form in the right of that interactive text.
I have inform all the codes as well as an image of the output right now and the image inside the slider:
The image inside the slider:
The output of the code right now:
Desired outcome:
This is the CSS + HTML code of the text :
<div class="container-wrap">
<aside id="fh5co-hero">
<div class="flexslider">
<ul class="slides">
<li style="background-image: url(images/graduation1.png);">
<div class="overlay-gradient"></div>
<div class="container-fluid">
<div class="row">
<div class="col-md-6 col-md-offset-3 col-md-pull-3 slider-text">
<div class="wrapper">
<div class="typing-demo">
Hello!
<br> Welcome to the website- </br>
</div>
</div>
<style>
.wrapper {
height: 50vh;
/*This part is important for centering*/
display: flex;
align-items: center;
justify-content: center;
}
.typing-demo {
width: 22ch;
animation: typing 2s steps(22), blink .5s step-end infinite alternate;
white-space: nowrap;
overflow: hidden;
border-right: 2px solid;
font-family: monospace;
font-size: 2.3em;
color: #FFFFFF
}
#keyframes typing {
from {
width: 0
}
}
#keyframes blink {
50% {
border-color: transparent
}
}
</style>
**this is the CSS + HTML code of the form :**
<html>
<div class="container"></div>
<div class="form">
<div class="thumbnail"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/hat.svg"/></div>
<form class="register-form">
<input type="text" placeholder="name"/>
<input type="password" placeholder="password"/>
<input type="text" placeholder="email address"/>
<button>create</button>
<p class="message">Already registered? Sign In</p>
</form>
<form class="login-form">
<input type="text" placeholder="Email"/>
<input type="password" placeholder="Password"/>
<button>login</button>
<p class="message">Are you a Business/Society? Register here</p>
</form>
</div>
</html>
<style>
.form {
position: relative;
z-index: 1;
background: #FFFFFF;
max-width: 300px;
margin: right;
padding: 60px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
text-align: center;
}
.form .thumbnail {
background: #ffd700;
width: 150px;
height: 150px;
margin: 0 auto 30px;
padding: 50px 30px;
border-top-left-radius: 100%;
border-top-right-radius: 100%;
border-bottom-left-radius: 100%;
border-bottom-right-radius: 100%;
box-sizing: border-box;
}
.form .thumbnail img {
display: block;
width: 100%;
}
.form input {
outline: 0;
background: #f2f2f2;
width: 100%;
border: 0;
margin: 0 0 15px;
padding: 15px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
box-sizing: border-box;
font-size: 14px;
}
.form button {
outline: 0;
background: #ffd700;
width: 100%;
border: 0;
padding: 15px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
color: #FFFFFF;
font-size: 14px;
transition: all 0.3 ease;
cursor: pointer;
}
.form .message {
margin: 15px 0 0;
color: #b3b3b3;
font-size: 12px;
}
.form .message a {
color: #ffd700;
text-decoration: none;
}
.form .register-form {
display: none;
}
.container {
position: relative;
z-index: 1;
max-width: 300px;
margin: 0 auto;
}
.container:before, .container:after {
content: "";
display: block;
clear: both;
}
.container .info {
margin: 50px auto;
text-align: center;
}
.container .info h1 {
margin: 0 0 15px;
padding: 0;
font-size: 36px;
font-weight: 300;
color: #1a1a1a;
}
.container .info span {
color: #4d4d4d;
font-size: 12px;
}
.container .info span a {
color: #000000;
text-decoration: none;
}
.container .info span .fa {
color: #ffd700;
}
/* END Form */
</style>
I think I found a solution to your problem. The main thing you where missing is display: inline-block; This allows DIVs to be next to each other.
.flexslider {
display: inline-block;
width: 100%;
}
.row {
float: left;
}
.container {
float: right;
}

How to align center the box div responsively?

This is my html file
body {
background-color: rgb(231, 59, 59);
font-family: "Alata";
font-size: 20px;
margin: 30px;
}
h1 {
margin-top: 100px;
color: #202124;
text-align: center;
}
.box {
width: 1000px;
}
input {
position: relative;
display: inline-block;
box-sizing: border-box;
}
input[type="text"] {
background: #fff;
width: 600px;
height: 50px;
padding: 0 10px;
border: none;
outline: none;
border-radius: 25px 0 0 25px;
font-size: 15px;
}
button {
left: -5px;
position: relative;
border-radius: 0 25px 25px 0;
width: 110px;
height: 50px;
border: none;
outline: none;
cursor: pointer;
background: #ffc170;
color: #fff;
font-size: 21px;
}
<h1>This is my page title...</h1>
<div class="box">
<form>
<input type="text" name="" placeholder="Search here" />
<button type="button">Search</button>
</form>
</div>
My question is how can I align the box div align center(horizontally) responsively(dynamically) and how to make this webpage responsive when I checked this page's responsiveness it's not showing responsiveness.
Try this code:
body {
background-color: rgb(231, 59, 59);
font-family: "Alata";
font-size: 20px;
margin: 30px;
}
h1 {
margin-top: 100px;
color: #202124;
text-align: center;
}
.box {
max-width: 1000px;
width:100%;
margin:0 auto;
}
input {
position: relative;
display: inline-block;
box-sizing: border-box;
}
input[type="text"] {
background: #fff;
width: 600px;
height: 50px;
padding: 0 10px;
border: none;
outline: none;
border-radius: 25px 0 0 25px;
font-size: 15px;
}
button {
left: -5px;
position: relative;
border-radius: 0 25px 25px 0;
width: 110px;
height: 50px;
border: none;
outline: none;
cursor: pointer;
background: #ffc170;
color: #fff;
font-size: 21px;
}
<h1>This is my page title...</h1>
<div class="box">
<form>
<input type="text" name="" placeholder="Search here" />
<button type="button">Search</button>
</form>
</div>
What I have done is that I have changed the
.box {
width: 1000px;
}
to
.box {
max-width: 1000px;
width:100%;
margin:0 auto;
}
You can also use display: flexbox; and justify-content: center; in the div box to get almost the same result
Here is the code that I think will work if you want to use flexbox:
body {
background-color: rgb(231, 59, 59);
font-family: "Alata";
font-size: 20px;
margin: 30px;
}
h1 {
margin-top: 100px;
color: #202124;
text-align: center;
}
.box {
display: flexbox;
justify-content: center;
}
input {
position: relative;
display: inline-block;
box-sizing: border-box;
}
input[type="text"] {
background: #fff;
width: 600px;
height: 50px;
padding: 0 10px;
border: none;
outline: none;
border-radius: 25px 0 0 25px;
font-size: 15px;
}
<h1>This is my page title...</h1>
<div class="box">
<form>
<input type="text" name="" placeholder="Search here" />
<button type="button">Search</button>
</form>
</div>
NOTE I have used max-widht: 1000px; in my first method, you can change that as per need.
Change this
.box{
max-width: 1000px;
width:100%;
margin:0 auto;
}
use this but the condition is your parent div has 100% width(window width).
or another way to use flex
form{
width: 200px;
margin: auto;
}
<body>
<h1>This is my page title...</h1>
<div class="box">
<form>
<input type="text" name="" placeholder="Search here">
<button type="button">Search</button>
</form>
</div>
</body>
You can follow the below code. I try to give some explanation where I changed and why I did it
body {
background-color: rgb(231, 59, 59);
font-family: "Alata";
font-size: 20px;
margin: 0px;
}
h1 {
margin-top: 100px;
color: #202124;
text-align: center;
}
.box {
/*if you want to take result as a responsive then you need to add width as % not fixt size */
width: 100%;
text-align: center;
margin: 0 auto;
}
/*This div for form responsive */
.search-form{
width: 90%;
text-align: center;
margin: 0 auto;
}
input {
position: relative;
display: inline-block;
box-sizing: border-box;
}
input[type="text"] {
background: #fff;
width: 70%; /* I change here for px to % base one your requerment */
height: 50px;
padding: 0 10px;
border: none;
outline: none;
border-radius: 25px 0 0 25px;
font-size: 15px;
float: left; /* I change here for div assign as a left */
}
button {
position: relative;
border-radius: 0 25px 25px 0;
width: 30%; /* I change here for px to % base one your requerment */
height: 50px;
border: none;
outline: none;
cursor: pointer;
background: #ffc170;
color: #fff;
font-size: 21px;
float: left; /* I change here for div assign as a left */
}
<h1>This is my page title...</h1>
<div class="box">
<div class="search-form">
<form>
<input type="text" name="" placeholder="Search here" />
<button type="button">Search</button>
</form>
</div>
</div>
display: block fix needs these two blocks to be inserted in the css
.box {
max-width: 1000px;
margin: 0 auto;
}
form {
width: max-content;
margin: 0 auto;
}
Working Fiddle
body {
background-color: rgb(231, 59, 59);
font-family: "Alata";
font-size: 20px;
margin: 30px;
}
h1 {
margin-top: 100px;
color: #202124;
text-align: center;
}
.box {
max-width: 1000px;
margin: 0 auto;
}
form {
width: max-content;
margin: 0 auto;
}
input {
position: relative;
display: inline-block;
box-sizing: border-box;
}
input[type="text"] {
background: #fff;
width: 600px;
height: 50px;
padding: 0 10px;
border: none;
outline: none;
border-radius: 25px 0 0 25px;
font-size: 15px;
}
button {
left: -5px;
position: relative;
border-radius: 0 25px 25px 0;
width: 110px;
height: 50px;
border: none;
outline: none;
cursor: pointer;
background: #ffc170;
color: #fff;
font-size: 21px;
}
<h1>This is my page title...</h1>
<div class="box">
<form>
<input type="text" name="" placeholder="Search here" />
<button type="button">Search</button>
</form>
</div>
If you are good to go with flexbox implementation, you could wrap your .box in flex and have a justify-content: center; to have an horizontal alignment.
Add the below update in your css for flexbox
.box {
display: flex;
justify-content: center;
}
Working flexbox fiddle
body {
background-color: rgb(231, 59, 59);
font-family: "Alata";
font-size: 20px;
margin: 30px;
}
h1 {
margin-top: 100px;
color: #202124;
text-align: center;
}
.box {
max-width: 1000px;
display: flex;
justify-content: center;
}
input {
position: relative;
display: inline-block;
box-sizing: border-box;
}
input[type="text"] {
background: #fff;
width: 600px;
height: 50px;
padding: 0 10px;
border: none;
outline: none;
border-radius: 25px 0 0 25px;
font-size: 15px;
}
button {
left: -5px;
position: relative;
border-radius: 0 25px 25px 0;
width: 110px;
height: 50px;
border: none;
outline: none;
cursor: pointer;
background: #ffc170;
color: #fff;
font-size: 21px;
}
<h1>This is my page title...</h1>
<div class="box">
<form>
<input type="text" name="" placeholder="Search here" />
<button type="button">Search</button>
</form>
</div>
Please note I have made use of max-width: 1000px; for .box in both examples. This is to make sure that the ui wont fail in the SO fiddle. You can update that as your requirement.

Different renditions on firefox and chrome of search bar

Hi I have created the following search bar:
<div class="container-fluid">
<div class="search-bar">
<form class="searchBar">
<div class="row" >
<div class="allElements">
<div class="input-group" >
<span style="color:black" class="input-group-addon">
<select id="selection" onchange="getValues(this.value)">
<option>Choose Category</option>
<option>All</option>
<option>Notary</option>
<option>Deed Date</option>
<option>Person</option>
<option>Place</option>
<option>Register Reference</option>
<option>Subject</option>
</select>
</span>
<div class="autocomplete" style ="width:400px">
<input id="search" type="text" class="form-control" name="search" placeholder="Choose a category" style ="width:400px" disabled=true>
</div>
<span class="input-group-addon" style="color:black"> <button type="button" onclick="doSparql(this.value)">Search</button></span>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
Where on firefox is rendered perfectly while on the chrome, the search button is on the other side of the screen not grouped with the rest of the search bar as shown in the picture below. Any idea why this is happening and how I can solve it pls?
The css is:
-moz-webkit-margin:0px
html, body {
max-width: 100%;
overflow-x: hidden;
}
.footer-div {
display: inline;
height: 100%;
}
.panel-footer
{
position: fixed;
bottom: 0;
width: 100%;
padding: 0px 0px;
background-color: rgba(70,131,172,1);
height: 10%;
max-height: 50px;
border-color: #fff;
border-top: 0px solid #ddd;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
z-index: 100;
}
.container-midvalign
{
height:100%;
padding: 0 0;
vertical-align: middle;
display: inline-table;
text-align: left;
}
.contents-midvalign
{
font-weight: bold;
color: #FFFFFF;
font-size: 14px;
vertical-align:middle;
display: table-cell;
text-align: left;
position: relative
}
.contents-midvalign:hover
{
color: #fff;
text-decoration: underline;
}
.footer-img {
background: url(../media/icons/MALTA_COAT_OF_ARMS_WHITE.png) no-repeat;
height: 100%;
max-height: 50px;
background-size: contain;
position: relative;
padding: 0px 0px;
margin-left: 25px;
margin-right: 10px;
margin-top: 0px;
margin-bottom: 0px;
vertical-align: middle;
background-color: transparent;
border: 0px solid transparent;
border-radius: 0px;
}
.footer-div
{
display: inline;
height: 100%;
}
.footer-icon
{
font-size: 24px;
padding-right: 25px;
}
.footer-icon:hover
{
text-decoration: none;
}
.bg-gemma
{
background-color: rgba(70,131,172,1) !important;
}
.bg-transparent
{
background-color: transparent !important;
border-color: transparent !important;
box-shadow: 0 0 0 0 rgba(108,117,125,0) !important;
}
.navbar
{
/* height: 10%;*/
min-height: 50px;
/* overflow: hidden;*/
margin: 0 auto;
padding: 0px;
position: fixed;
border: 0px solid transparent;
width: 100%;
background-color: rgba(70,131,172,1);
}
.fixed-top {
position: fixed;
top: 0;
right: 0;
left: 0;
z-index: 1030;
}
h2{
font-weight: bold;
color: black;
font-size: 40px;
position: relative;
}
#headerdiv {
margin-top: 10px;
margin-bottom: 10px;
}
#fullpagecont
{
padding-left: 25px;
padding-right: 25px;
}
#pheader
{
text-align: center;
}
html body .container-fluid.body-content {
position: absolute;
top: 50px;
bottom: 50px;
right: 0;
left: 0;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
select {
background: transparent;
border: none;
padding: 6px 12px;
}
.input-group-addon {
padding: 0!important;
}
#results{
margin-left: 120px;
margin-right: 120px;
position: relative;
}
.add_data{
margin-left: 150px;
width:20%;
margin-top:5px;
text-align:center;
}
.search-bar{
position: absolute;
left: 35%;
top:130px;
}
.autocomplete {
/*the container must be positioned relative:*/
position: relative;
}
.autocomplete-items {
position: absolute;
text-align: left;
border: 1px solid #d4d4d4;
border-bottom: none;
border-top: none;
z-index: 99;
/*position the autocomplete items to be the same width as the container:*/
top: 100%;
left: 0;
right: 0;
}
button {
padding: 6px 12px;
background: transparent;
border: none;
}
.autocomplete-items div {
padding:10px;
cursor: pointer;
background-color: #fff;
border-bottom: 1px solid #d4d4d4;
}
.autocomplete-items div:hover {
/*when hovering an item:*/
background-color: #e9e9e9;
}
.autocomplete-active {
/*when navigating through the items using the arrow keys:*/
background-color: DodgerBlue !important;
color: #ffffff;
}
#div_pagination{
width:100%;
margin-top:5px;
text-align:center;
}
#div_pagination_all{
width:100%;
margin-top:5px;
text-align:center;
}
#pageNo{
text-align:center;
margin-top: 20px;
}
#main-container{
margin-top: 200px;
width:90%;
margin-left: 75px;
}
#details{
margin-top: 25px;
margin-left: 25px;
}
.deedList{
margin-left: 15px;
}
#media (max-width: 575px)
{
.footer-icon
{
padding-right: 10px;
}
.footer-img
{
margin-left: 10px;
}
}
I saw this in chrome:
and this in FF:
To get on the line I added this:
.autocomplete {
position: relative;
display: inline-block;
}

Switching my element to "position: absolute" prevents it form taking up full width

My login page looks and acts how I want it to when my container div is set to display: block and position: static. However, when it becomes either display: inline-block or position: absolute, it stops taking up its max width of 500px. I want to use absolute positioning to center my div vertically and horizontally, so I need the layout to stay the same as it looks when it has static position. How can I achieve this?
* {
-moz-box-sizing: border-box !important;
-webkit-box-sizing: border-box !important;
box-sizing: border-box !important;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
#login-box {
max-width: 500px;
min-width: 300px;
box-shadow: #bbb 0 0 20px 0;
display: block;
position: static;
/*position: absolute;*/
}
#HeaderForLoginForm {
background-image: url('https://dummyimage.com/600x106/333333/fff.png&text=SOME+LOGO');
background-repeat: no-repeat;
background-size: 200px;
background-position-x: center;
background-position-y: 25px;
background-color: #000;
height: 110px;
text-align: center;
line-height: 56px;
}
#headerlinks {
color: rgb(90, 90, 90);
font-weight: bold;
font-size: 12px;
margin-top: 54px;
display: inline-block;
}
#media (min-width: 450px) {
#HeaderForLoginForm {
background-position-x: 25px;
background-position-y: center;
text-align: right;
height: 95px;
line-height: 95px;
}
#headerlinks {
margin-right: 20px;
margin-top: 0;
}
}
#DivForLoginForm {
background: #b7d9ff;
background: -webkit-linear-gradient(#b7d9ff, #fff);
background: -o-linear-gradient(#b7d9ff, #fff);
background: -moz-linear-gradient(#b7d9ff, #fff);
background: linear-gradient(#b7d9ff, #fff);
text-align: center;
}
#LoginForm {
display: inline-block;
width: 74%;
margin-top: 20px;
margin-bottom: 40px;
}
#LoginForm input.textField {
display: inline-block;
width: 100%;
padding: 10px;
margin-top: 18px;
font-size: 14px;
border-radius: 3px;
border: 1px solid #999;
}
#terms-wrapper {
margin-top: 16px;
margin-bottom: 30px;
text-align: left;
font-size: 14px;
font-weight: bold;
}
#terms-wrapper input {
margin-left: 0;
vertical-align: -2px;
}
a[href] {
color: #0079dd;
text-decoration: none;
}
a[href]:hover {
text-decoration: underline;
}
input#btn-login {
padding: 14px;
height: auto;
width: 40%;
min-width: 100px;
float: right;
background-color: #1064d8;
color: #fff;
font-weight: bold;
font-size: 16px;
outline: none !important;
border: none;
border-radius: 3px;
cursor: pointer;
}
input#btn-login:hover {
background-color: #004BBF;
}
input#btn-login:active {
background-color: #0031A5;
}
#loginfooter {
background-image: url("http://images.naldzgraphics.net/2014/08/20-brushed-seamless-texture.jpg");
color: rgb(100, 100, 100);
padding: 12px;
font-size: 11px;
}
[data-val-required] {
background-color: #fff;
}
<section id="login-box-wrapper">
<div id="login-box">
<header id="HeaderForLoginForm">
<div id="headerlinks">
some link |
some other link
</div>
</header>
<div id="DivForLoginForm">
<form method="post" id="LoginForm">
<input class="textField" id="UserName" name="UserName" placeholder="Username" type="text">
<input class="textField" id="Password" name="Password" placeholder="Password" type="password">
<div id="terms-wrapper">
<input id="HasAcceptedTermsConditions" name="HasAcceptedTermsConditions" type="checkbox">
<label for="HasAcceptedTermsConditions">
I agree to the <a id="terms-link" href="#" target="_blank">General Terms of Service</a>
</label>
</div>
<input id="btn-login" type="submit" value="LOG IN">
</form>
</div>
<footer id="loginfooter" style="text-align: center;">
<span>© 2009-2017 Some Company, LLC — All rights reserved</span>
</footer>
</div>
</section>
Add width: 100%; to #login-box to get it to take up the max-width rule.
Use position: absolute; with top, left and transform with the translate function to horizontally and vertically center the login box.
#login-box {
width: 100%;
max-width: 500px;
min-width: 300px;
box-shadow: #bbb 0 0 20px 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate( -50%, -50% );
}
* {
-moz-box-sizing: border-box !important;
-webkit-box-sizing: border-box !important;
box-sizing: border-box !important;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
#login-box {
width: 100%;
max-width: 500px;
min-width: 300px;
box-shadow: #bbb 0 0 20px 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate( -50%, -50% );
}
#HeaderForLoginForm {
background-image: url('https://dummyimage.com/600x106/333333/fff.png&text=SOME+LOGO');
background-repeat: no-repeat;
background-size: 200px;
background-position-x: center;
background-position-y: 25px;
background-color: #000;
height: 110px;
text-align: center;
line-height: 56px;
}
#headerlinks {
color: rgb(90, 90, 90);
font-weight: bold;
font-size: 12px;
margin-top: 54px;
display: inline-block;
}
#media (min-width: 450px) {
#HeaderForLoginForm {
background-position-x: 25px;
background-position-y: center;
text-align: right;
height: 95px;
line-height: 95px;
}
#headerlinks {
margin-right: 20px;
margin-top: 0;
}
}
#DivForLoginForm {
background: #b7d9ff;
background: -webkit-linear-gradient(#b7d9ff, #fff);
background: -o-linear-gradient(#b7d9ff, #fff);
background: -moz-linear-gradient(#b7d9ff, #fff);
background: linear-gradient(#b7d9ff, #fff);
text-align: center;
}
#LoginForm {
display: inline-block;
width: 74%;
margin-top: 20px;
margin-bottom: 40px;
}
#LoginForm input.textField {
display: inline-block;
width: 100%;
padding: 10px;
margin-top: 18px;
font-size: 14px;
border-radius: 3px;
border: 1px solid #999;
}
#terms-wrapper {
margin-top: 16px;
margin-bottom: 30px;
text-align: left;
font-size: 14px;
font-weight: bold;
}
#terms-wrapper input {
margin-left: 0;
vertical-align: -2px;
}
a[href] {
color: #0079dd;
text-decoration: none;
}
a[href]:hover {
text-decoration: underline;
}
input#btn-login {
padding: 14px;
height: auto;
width: 40%;
min-width: 100px;
float: right;
background-color: #1064d8;
color: #fff;
font-weight: bold;
font-size: 16px;
outline: none !important;
border: none;
border-radius: 3px;
cursor: pointer;
}
input#btn-login:hover {
background-color: #004BBF;
}
input#btn-login:active {
background-color: #0031A5;
}
#loginfooter {
background-image: url("http://images.naldzgraphics.net/2014/08/20-brushed-seamless-texture.jpg");
color: rgb(100, 100, 100);
padding: 12px;
font-size: 11px;
}
[data-val-required] {
background-color: #fff;
}
<section id="login-box-wrapper">
<div id="login-box">
<header id="HeaderForLoginForm">
<div id="headerlinks">
some link |
some other link
</div>
</header>
<div id="DivForLoginForm">
<form method="post" id="LoginForm">
<input class="textField" id="UserName" name="UserName" placeholder="Username" type="text">
<input class="textField" id="Password" name="Password" placeholder="Password" type="password">
<div id="terms-wrapper">
<input id="HasAcceptedTermsConditions" name="HasAcceptedTermsConditions" type="checkbox">
<label for="HasAcceptedTermsConditions">
I agree to the <a id="terms-link" href="#" target="_blank">General Terms of Service</a>
</label>
</div>
<input id="btn-login" type="submit" value="LOG IN">
</form>
</div>
<footer id="loginfooter" style="text-align: center;">
<span>© 2009-2017 Some Company, LLC — All rights reserved</span>
</footer>
</div>
</section>
Be careful when using width: 100% on elements removed from the normal flow of the document.
Using right: 0 instead of width: 100% could be prefered for consistency, it depends on which results you are expecting when using margins in these elements.
Using width: 100%.
div {
height: 20vh;
border: .2em solid violet;
box-sizing: border-box;
}
.relative {
position: relative;
}
.absolute {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-color: dodgerblue;
margin: .5em;
}
<div class="relative">
<div class="absolute"></div>
</div>
Using right: 0.
div {
height: 20vh;
border: .2em solid violet;
box-sizing: border-box;
}
.relative {
position: relative;
}
.absolute {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-color: dodgerblue;
margin: .5em;
}
<div class="relative">
<div class="absolute"></div>
</div>