Centering a BootStrap well - html

I am trying to center a Bootstrap Well that says "Resource Booker" within a div so that it aligns properly with the two boxes below it. Ive tried adding padding but it adds padding inside of the well. I provided a picture and my code below.
Page Screenshot
<div class="col-sm-8 text-left">
<br>
<br>
<div class="well well-lg" style="background-color:rgb(0,50,0); color:white;"><h1> Resource Booker </h1> </div>
<br>
<br>
<div class="row">
<div class="column">
<div class="card" id="hi" style="width:400px; height:300px;">
<p><i class="fa fa-user"></i></p>
<h1>Book</h1>
<p>Book A Room</p>
<p> <span class="glyphicon glyphicon-book" style="font-size:150px;"></span></p>
</div>
</div>
<center>
<div class="column">
<br>
</div>
<div class="column">
<div class="card" id="bye" style="width:400px; height:300px;>
<p><i class="fa fa-coffee"></i></p>
<h1>Calender</h1>
<p>Check Availability</p>
<p> <span class="glyphicon glyphicon-calendar" style="font-size:150px;"></span></p>
</div>
</div>
</div>
</div>
</center>
</div>
The CSS for the cards underneath the well is:
/* Float four columns side by side */
.column {
float:left;
width: 27%;
padding: 0px 50px 0px 90px;
}
.row {margin: 0 -5px;}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive columns */
#media screen and (max-width: 600px) {
.column {
width: 100%;
display: block;
margin-bottom: 10px;
}
}
/* Style the counter cards */
.card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
padding: 16px;
text-align: center;
background-color: #444;
color: white;
}
.fa {font-size:200px;

Try adding the container class wrapped around the div. You can also add margin-left to the same. Further, please add a codepen of your project so that we mobile users can play around for the solution.

If you add margin-left to div then you have to adjust that margin in media query it's better to give max-width to well dive and give them margin: 0 auto and width: 100%.
Your css will like this
.well{max-width: 400px; width: 100%; margin: 0 auto;}

Related

How to leave minor div after major div on the same line?

I am scaling several divs and have one that is larger than the others in width and height, the other divs that are after this one are too low, not aligned on the same line.
Note: execute the code below on full page, Follows the code:
body {
background-color: #2E5173;
}
div {
border-radius: 10px;
background-color: white;
margin: 10px;
width: 240px;
height: 250px;
display: inline-block;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12)!important;
}
.big {
width: 508px;
height: 508px;
}
<div class=""> </div>
<div class=""> </div>
<div class=""> </div>
<div class=""> </div>
<div class=""> </div>
<div class=""> </div>
<div class=""> </div>
<div class=""> </div>
<div class="big"> </div>
<div class="">this div is very low</div>
<div class="">this div is very low</div>
The code above looks like this:
I need it to look like this:
Can anyone help?
You can easily do this using CSS grid:
.container {
display:grid;
grid-template-columns:repeat(auto-fit,240px); /* The width */
grid-auto-rows:250px; /* The height */
grid-auto-flow:dense; /*This is the important property*/
/* The margin */
grid-gap:20px;
padding:10px;
}
.container div {
border-radius: 10px;
background-color: #2E5173;
}
.big {
grid-column:span 2; /* Take twice the width*/
grid-row:span 2; /* Take twice the height*/
}
<div class="container">
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div class="big"> </div>
<div>this div is very low</div>
<div>this div is very low</div>
</div>
CSS Grid can provide you with great control of your layouts and is not super complicated. A few of the resources I've used in the last are listed below:
www.w3schools.com/css/css_grid.asp
learncssgrid.com
css-tricks.com/snippets/css/complete-guide-grid
CSS Grid also works well with media queries if you need the page to be responsive.

Centering grouped inline elements issue

I have a section that I want to look as if it is centered on the page. I have four boxes that appear inline and I believe the reason they do not like they are centered is because everything is aligned naturally to the left. The thing is, I do not want the content that is in these boxes to be centered, I want them aligned left.
So how can I make the boxes appear as if they are centered within the page, but not have it affect my text?
#contact-connect {
width: 80%;
height: auto;
margin: 0 10%;
padding: 80px 0;
}
#contact-connect-box-container {
margin: 0 auto;
width: auto;
}
.contact-connect-box {
width: 25%;
margin: 60px 0 0 0;
display: inline-block;
border: 1px solid black;
vertical-align: top;
transition:1s; -webkit-transition:1s;
}
<div id="contact-connect">
<div id="contact-connect-box-container">
<div class="contact-connect-box">
<h2 class="contact-connect-title">Call</h2>
<div class="contact-connect-description">vcxv</div>
</div>
<div class="contact-connect-box">
<h2 class="contact-connect-title">Write</h2>
<div class="contact-connect-description">
Reach out to us
<br>
<div id="scroll" class="contact-connect-link">Fill out our contact form.</div>
</div>
</div>
<div class="contact-connect-box">
<h2 class="contact-connect-title">Visit</h2>
<div class="contact-connect-description">
fgrge
</div>
</div>
<div class="contact-connect-box">
<h2 class="contact-connect-title">Connect</h2>
<div class="contact-connect-description">
<div class="contact-connect-link">Visit us on Facebook</div>
<div class="contact-connect-link">See us on Youtube</div>
<div class="contact-connect-link"></div>
</div>
</div>
</div>
</div>
You can just add "display: flex" on your #contact-connect-box-container
#contact-connect-box-container {
margin: 0 auto;
width: auto;
display: flex;
}
DEMO :
https://jsfiddle.net/w776Lq1u/8/
The problem is the margin on the right side of "Connect." I would recommend using flexbox and using display: flex; justify-content: space-around; That way you won't need any margins at all.
EDIT: plnkr

Trouble with divs?

Okay, I'm very new to CSS and only minimally familiar with HTML so I'm still kind of fumbling around with both of them. I'm building a practice site and I can't figure out what I'm doing wrong here. My goal is to have the image box to the left of the header and paragraph, but have the title on the same line as the top of the image. Here's what I have:
<img src="" />
<div class="bios">
<h4>First Last</h4>
<p>This is my bio</p>
</div>
Paired with this CSS:
.bios {
height: 100px;
width: auto;
display: inline;
background-color: #a78ffc;
clear: left;
display: inline;
/** top, right, bottom, left **/
margin: 1px 1px 1px 10px;
/** top, right, bottom, left **/
padding: 1px 1px 1px 10px
}
img {
height: 100px;
width: 100px;
float: left;
clear: left;
display: inline;
}
I added the background color to really see what's going on in the preview and I'm more confused than ever. This is how it's displaying:
http://i1126.photobucket.com/albums/l618/spenciecakes/Screen%20Shot%202016-05-13%20at%2010.41.45%20AM_zps50dajzko.png
EDIT
Okay, I've added the additional code as requested and I've added the display: inline to both elements but honestly it all appears the same..
I can't solve your problem with only the code you provided (what's the code for the images?), but I can tell you what's wrong with the current code. First, in order for the width and height property to work, the display property needs to be set to either inline-block or block.
Secondly, the float property does not have a value center. It can only take the values left and right (you need to the first one in this case).
The negative margin trick works like a charm (Explanation in code comments)
.bio {
overflow: hidden; /* Prevent negative margin from leaking out */
}
.bio-inner {
overflow: hidden; /* Clearfix */
margin-left: -1em; /* A) Remove spacing between items when they are against the left side (Must be negative B) */
}
.bio-thumbnail {
height: 3em;
width: auto;
background-color: #a78ffc;
}
.bio-thumbnail,
.bio-info {
float: left;
margin-left: 1em; /* B) Add spacing between items (Must be positive A) */
}
.bio-info-heading {
margin: 0em; /* Just removing default margins */
}
.bio-info-text {
margin-top: 0.5em;
}
<div class="bio">
<div class="bio-inner">
<img class="bio-thumbnail" src="http://i.stack.imgur.com/7bI1Y.jpg">
<div class="bio-info">
<h4 class="bio-info-heading">First Last</h4>
<p class="bio-info-text">This is my bio</p>
</div>
</div>
</div>
This, I have found, works best in cases where screens may be too small to fit the image and text side-by-side.
You can use display: inline-block.
.inline {
display: inline-block;
}
.title {
font-weight: bold;
}
<div>
<div class="inline">
<img src="http://placehold.it/50x50" />
</div>
<div class="inline">
<div class="title">Item 1</div>
<p>Item 1 description</p>
</div>
</div>
<div>
<div class="inline">
<img src="http://placehold.it/50x50" />
</div>
<div class="inline">
<div class="title">Item 2</div>
<p>Item 2 description</p>
</div>
</div>

Responsive CSS behaviour of a centered image

I cannot get the image container (.colored-logo) to span the width of the browser when I shrink it to mobile size. I have created a fiddle here so you can see the behaviour.
Apologies but I have placed all my CSS in here to make sure that whatever it is affecting it is included.
I am working on an email template and I am centering horizontally and vertically a logo into a boxed area with rounded corners.
My HTML is:
<div class="row invoice-top-header">
<div class="column third colored-logo">
<div class="logo">
<span class="image-center"></span><img src="http://s24.postimg.org/ebd3rwub5/fresh_creations_logo.png"/>
</div>
</div>
<div class="column third">...</div>
<div class="column third">...</div>
</div>
The row class adds a 15px internal padding which I offset in the container (colored-logo) with a -15px margin left and right.
The CSS I apply is this:
.colored-logo {
background: #989898;
height: 128px;
margin: 0px -15px 10px -15px;
padding: 15px;
width: 100%;
}
.logo {
white-space: nowrap;
text-align: center;
}
.image-center {
display: inline-block;
height: 100%;
vertical-align: middle;
}
Why is the logo container (div with class colored-logo, dark grey background) not filling the browser horizontally once in mobile mode? It looks to be 30px too short to cover the browser horizontally.Thanks!
It seems you have padding both to your row class and your column.
Try this css if you want your changes to take effect only in mobile screens:
#media screen and (max-width: 640px) {
.colored-logo, .row {
padding: 0;
margin: 0;
}
}
<div class="invoice-top-header">
<div class="column third colored-logo">
<div class="logo">
<span class="image-center"><img src="http://s24.postimg.org/ebd3rwub5/fresh_creations_logo.png"/>
</div>
</div>
<div class="row">
<div class="column third">
<div class="biller-details">
<span><strong>BILLER NAME PTY LTD</strong></span>
<span>ADDRESS LINE 1</span>
<span>ADDRESS LINE 2</span>
<span class="desktop">TEL: 02 3333 4444</span>
<span class="mobile">TEL: 02 3333 4444</span>
<span>ABN: 12345678</span>
<span>ACN: 09876543</span>
<span>sample#email.com</span>
<span>my-website.com.au</span>
</div>
</div>
<div class="column third">
<div class="customer-details">
<span><strong>CUSTOMER NAME PTY LTD</strong></span>
<span>ADDRESS LINE 1</span>
<span>ADDRESS LINE 2</span>
<span class="desktop">TEL: 02 5555 7777</span>
<span class="mobile">TEL: 02 5555 7777</span>
<span>ABN: 12345678</span>
<span>ACN: 09876543</span>
<span>sample#email.com</span>
<span>customer-website.com.au</span>
</div>
</div>
</div>
</div>
Change your HTML into this one above
Remove margin css property from .colored-logo
If you are coding a newsletter you should really consider using tables and avoid css3 properties as many of the email clients still doesnt support lot of things. Here you can find a list with email clint which does and doesnt support media queries:
https://litmus.com/help/email-clients/media-query-support/
Just tested and it works
Disabling these values / properties seems to work
.row {
margin: 0 auto;
/* padding: 15px; */
max-width: 1040px;
width: 100%;
}
.colored-logo {
background: #989898;
height: 128px;
/* margin: 0px -15px 10px -15px; */
padding: 15px;
width: 100%;
}
Just adjust as required in your media queries.
JSfiddle Demo

Improper formatting on an HTML page with CSS

I am designing a basic site where you can play rock paper scissors against the computer. The functionality is working perfectly, now I just need to tweak the format of the page.
I like the idea of having the game, and then underneath after a game, a message and button to restart appear, and should be centered under the page. Currently, these are being displayed to the right of my wrapper holding the actual game.
Here's my htm: the div and button are located at the bottom:
<div id="wrapper">
<div id="left" class="column">
<h2>User</h2>
<div id="userchoice">
</div>
</div>
<div id="middle" class="column">
<h2>VS.</h2>
</div>
<div id="right" class="column">
<h2>Rock Paper Scissors</h2>
<div id="computerchoice">
</div>
</div>
</div>
</br></br>
<div>
<p id="result"></p>
</div>
</br>
<button onclick="playAgain()" id="playagain" class="ui-button ui-widget ui-state-default ui-corner-all">Play Again?</button>
</br>
</br>
and my css:
body
{
text-align: center;
font-family: Verdana, Arial, sans-serif;
font-size: 1em;
}
#wrapper {
/*border: 2px solid black;*/
width: 1015px;
margin-left: auto;
margin-right: auto;
}
#header {
text-align: center;
}
/* 300px content + 20px = 320px physical width per column */
.column {
float: left;
width: 325px;
margin: 5px;
text-align: center;
min-height: 250px;
}
/* The middle column adds 4px of border to its physical width */
#middle {
/*border-left: 2px solid black;
border-right: 2px solid black;*/
margin-left: 0;
margin-right: 0;
padding-left: 10px;
padding-right: 10px;
}
/* CSS Clear Hack: apply this to the containing element. */
.group:before,
.group:after {
content:"";
display:table;
}
.group:after {
clear:both;
}
.group {
zoom:1; /* For IE 6/7 (trigger hasLayout) */
}
I've used this css on another page, and it functions as I want for the button and message at the bottom, so I'm quite baffled about how this isn't working. If you can spot an error or have something else I might try please let me know
Add a clear div to clear the height since you have floated elements.
<div id="wrapper">
<div id="left" class="column">
<h2>User</h2>
<div id="userchoice">
</div>
</div>
<div id="middle" class="column">
<h2>VS.</h2>
</div>
<div id="right" class="column">
<h2>Rock Paper Scissors</h2>
<div id="computerchoice">
</div>
</div>
<!-- clear here -->
<div class="clear" style="clear:both;"></div>
</div>