Bulma overlapping items - html

I'm using bulma.css for a layout, but when I give a border to something I've found its overlapping.
Here is the overlap:
The .shop div seems 'as expected'
But the .basket div seems to be creeping up a bit.
Here is a link to a demo
And Html:
<div id="app">
<div class="container">
<div class="shop">
<div class="columns">
<div class="column is-one-quarter product">
<h3 class="title is-4">Cat</h3>
<p>
£<span>2.99</span></p>
<div><button class="button">Add to basket</button></div>
</div>
<div class="column is-one-quarter product">
<h3 class="title is-4">Dog</h3>
<p>
£<span>4.00</span></p>
<div><button class="button">Add to basket</button></div>
</div>
</div>
</div>
<div class="basket">
<h1>Basket</h1>
<table class="table">
<thead>
<tr>
<td>Item</td>
<td>Quantity</td>
<td>Price</td>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">No items in the basket</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
CSS:
// All of bulma.css
html,body{
height:100%;
padding:20px;
}
.product{
box-sizing:border-box;
border:2px solid #eaeaea;
padding:20px;
}
I think its something to do with ... flexbox? I'm not sure!

In it's latest version try is-gapless along with columns class

The bottom container is creeping up over the top container because of this rule in the Bulma code:
.columns:last-child {
margin-bottom: -.75rem;
}
Just override it. Add this to your code:
.columns:last-child {
margin-bottom: 0 !important;
}
!important may not be necessary. I just added it to ensure that your rule prevails.

Related

How to align items properly using CSS flexbox

I am trying to achieve the following design in my code. I want to make the whole page responsive and put break points whenever necessary. So, I thought, It would be nice to implement this using CSS flexbox.I am kind of newbie with flexbox, so any helps would be highly appreciated. So, In my "section-two__main" div I have the items number and name. I want to display those items just like a table( as like the picture below). I could use css order property but then again I lost the responsiveness directly when shrinking the page. Can anybody guide me through this, if possible? How, can I achieve the design and maintain the responsiveness? At least before putting the breakpoints, Is it possible to adjust design so that when the page shrinks the items stay as like the actual design? I would like to use css flex box if possible. Thanks in Advance.
The design I would like to achieve:
And here is the code, that I have tried so far:
.wrapper{
display:flex;
flex-direction:column;
}
.section-one{
background-color:gray;
width:95%;
margin:0 auto;
}
.section-two{
background-color:white;
width:95%;
margin:0 auto;
margin-top:10px;
}
.section-two__header{
background-color:darkgray;
}
.section-two__footer{
background-color:darkgray;
}
.section-two__main{
background-color:white;
width:70%;
display:flex;
flex-direction:column;
margin:0 auto;
}
.name{
border:1px dotted;
}
.number{
border:1px dashed;
}
<div class="wrapper">
<div class="section-one">
First section
</div>
<div class="section-two">
<div class="section-two__header">
second section header
</div>
<div class="section-two__main">
<div class="number">1</div>
<div class="name">One</div>
<div class="number">2</div>
<div class="name">Two</div>
<div class="number">3</div>
<div class="name">Three</div>
<div class="number">4</div>
<div class="name">Four</div>
<div class="number">5</div>
<div class="name">Five</div>
<div class="number">6</div>
<div class="name">Six</div>
<div class="number">7</div>
<div class="name">Seven</div>
<div class="number">8</div>
<div class="name">Eight</div>
<div class="number">9</div>
<div class="name">Nine</div>
<div class="number">10</div>
<div class="name">Ten</div>
<div class="number">11</div>
<div class="name">Eleven</div>
<div class="number">12</div>
<div class="name">Twelve</div>
</div>
<div class="section-two__footer">
second section footer
</div>
</div>
</div>
Link to Fiddle: Demo
BreakPoint styles:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.wrapper {
display: flex;
flex-direction: column;
}
.name {
border: 1px dotted;
width: 8.3vw;
display: flex;
align-items: center;
justify-content: center;
}
.number {
border: 1px dashed;
width: 8.3vw;
display: flex;
align-items: center;
justify-content: center;
}
.oben {
display: flex;
align-items: center;
justify-content: center;
}
.unten {
display: flex;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="oben">
<div class="number">
<p>1</p>
</div>
<div class="number">
<p>2</p>
</div>
<div class="number">
<p>3</p>
</div>
<div class="number">
<p>4</p>
</div>
<div class="number">
<p>5</p>
</div>
<div class="number">
<p>6</p>
</div>
<div class="number">
<p>7</p>
</div>
<div class="number">
<p>8</p>
</div>
<div class="number">
<p>9</p>
</div>
<div class="number">
<p>10</p>
</div>
<div class="number">
<p>11</p>
</div>
<div class="number">
<p>12</p>
</div>
</div>
<div class="unten">
<div class="name">
<p>one</p>
</div>
<div class="name">
<p>two</p>
</div>
<div class="name">
<p>three</p>
</div>
<div class="name">
<p>four</p>
</div>
<div class="name">
<p>12</p>
</div>
<div class="name">
<p>12</p>
</div>
<div class="name">
<p>12</p>
</div>
<div class="name">
<p>12</p>
</div>
<div class="name">
<p>12</p>
</div>
<div class="name">
<p>12</p>
</div>
<div class="name">
<p>12</p>
</div>
<div class="name">
<p>12</p>
</div>
</div>
</div>
</body>
</html>
This should now be responsive
You can use flexbox yes, but simplify your HTML and CSS like this:
HTML
<div class="container"> <!-- this is the master container -->
<div class="sub-container">
<span>one</span>
<span>1</span>
</div>
<div class="sub-container">
<span>one</span>
<span>1</span>
</div>
<div class="sub-container">
<span>one</span>
<span>1</span>
</div>
<div class="sub-container">
<span>one</span>
<span>1</span>
</div>
<div class="sub-container">
<span>one</span>
<span>1</span>
</div>
<div class="sub-container">
<span>one</span>
<span>1</span>
</div>
<div class="sub-container">
<span>one</span>
<span>1</span>
</div>
<div class="sub-container">
<span>one</span>
<span>1</span>
</div>
<div class="sub-container">
<span>one</span>
<span>1</span>
</div> <div class="sub-container">
<span>one</span>
<span>1</span>
</div>
</div>
CSS
.container { /* seting ths master container to flex display creates a flexbox display with these DEFAULT values already built-in : flex-direction:row; */
display:flex;
}
.sub-container { /* same here flexbox, but we change to vertical flexbox with flex-direction:column; and we add align and justify to center to it aligns nicely centered in both axis X and Y */
display:flex;
flex-direction:column;
align-items:center;
justify-content:center;
border:1px solid black; /* this is your external border */
}
span {
margin:2px; /*this spaces things out a bit more nicely */
}
span:nth-child(2) { /* the nth-child() selector with (2) will select every SECOND 'span' element and give it a border-top */
border-top:1px solid black;width:100%;text-align:center; /* also we align the content of the second span and give it a full-width so that t he border-top is the full width of the sub-container */
}
I know you are asking about flexbox, but if you want to explore a different approach you can try using a table instead. That's exactly what they are made for. You could do something like this:
.table {
border-collapse: collapse;
}
table,
th,
td {
border: 1px solid black;
padding: 5px;
}
<table class="table">
<tr>
<th>one</th>
<th>two</th>
<th>three</th>
<th>four</th>
<th>five</th>
<th>six</th>
<th>seven</th>
<th>eight</th>
<th>nine</th>
<th>ten</th>
<th>eleven</th>
<th>twelve</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
</tr>
</table>

Removing extra spacing on top of a table

I'm creating a layout using div and table.
<div class="main-container bg-white">
<div class="main-content-container bg-blue">
<div class="logo-container">
<img src="http://thebrainfever.com/images/apple-logos/Silhouette.png" width="100px" height="100px"/>
</div>
<div class="menu-container">
Menu 1 | Menu 2
</div>
</div>
</div>
<div class="main-container bg-white">
<div class="main-content-container bg-yellow">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="wrapper">
<tr>
<td style="width: 100%; padding: 0px 5px; background-color: grey;" colspan="2">
Content
</td>
</tr>
</table>
</div>
</div>
https://jsfiddle.net/odtkrumL/
The layout seems OK except there is extra spacing at the top of the table such that the text "Content" is being pushed down a bit (the yellow spacing). How could I remove the extra (yellow) spacing?
As a quick fix add display:block to your .wrapper
.wrapper {
margin-left: auto;
margin-right: auto;
display: block;
}
Fiddle : https://jsfiddle.net/qr7byupa/
Please try this:
.bg-white {
background-color: #ffffff;
display:flex
}

How do you make HTML elements appear on a vertical line using CSS?

Image of the problem:
How do I go from the one on the left, to the one on the right, using CSS?
You can use a table:
<table>
<tr>
<td>You own</td>
<td>20</td>
</tr>
<tr>
<td>Price</td>
<td>20</td>
</tr>
<tr>
<td>BPS</td>
<td>0.50</td>
</tr>
</table>
or floating divs:
<div style="display:inline-block;">
<div style="float:left; width:150px;">You own</div>
<div style="float:left;">20</div>
</div>
<div style="display:inline-block;">
<div style="float:left; width:150px;">Price</div>
<div style="float:left;">20</div>
</div>
<div style="display:inline-block;">
<div style="float:left; width:150px;">BPS</div>
<div style="float:left;">0.50</div>
</div>
<div>
<div id="left"> <!-- float left -->
<p>You Own></p>
<p>Price</p>
<p>BPS</p>
</div>
<div id="right">
<p>20</p>
<p>20</p>
<p>0.50</p>
</div>
</div>
Two divs
<div class="box">
Your own:<br />
Price:<br />
PBS
</div>
<div class="box">
20<br />
20<br />
50
</div>
CSS
.box {
float:left;
padding-right:40px;
}
While I am in agreement that this can be a table, you can easily do this with floats.
.container {
padding: 0.5em;
width: 200px;
background: #333;
color: #fff;
}
.button {
background: #efefef;
padding: 5px;
color: #000;
margin-bottom: 0.5em;
}
.item-header {
font-weight:bold;
float:left;
width: 45%;
clear:both;
}
<div class="container">
<div class="button">Buy Foreign Worker</div>
<div class="items">
<div class="item-header">You Own:</div>
<div class="item-value">20</div>
<div class="item-header">Price:</div>
<div class="item-value">20</div>
<div class="item-header">BPS:</div>
<div class="item-value">0.5</div>
</div>
</div>
All you are doing is making the header values float to the left, and the clear ensures that it starts on a new row.

center table within div

I have a table within a div using the span12 class from twitter bootstrap which is contained within a row class div all surrounded by a footer tag as follows:
<footer class="footer">
<div class="row">
<div class="span12">
<table>
<tr>
<td> <!-- Contact Us -->
<table>
<tr>
<td><b>Contact Us</b></td>
</tr>
<tr>
<td>Tel: 01234 567897</td>
</tr>
<tr>
<td>E-mail: info#email.com</td>
</tr>
</table>
</td>
<td> <!-- Useful Links -->
<table>
<tr>
<td><b>Useful Links</b></td>
</tr>
<tr>
<td>Contact Us</td>
</tr>
<tr>
<td>About Us</td>
</tr>
<tr>
<td>Copyright Information</td>
</tr>
<tr>
<td>Terms & Conditions</td>
</tr>
</table>
</td>
<td> <!-- Social -->
<table>
<tr>
<td><b>Connect With Us</b></td>
</tr>
<tr>
<td>Facebook</td>
</tr>
<tr>
<td>Twitter</td>
</tr>
<tr>
<td>Google Plus</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</footer>
I have the following CSS applied:
/* Table Style */
.footer table {
table-layout:fixed;
margin-right: auto;
margin-left: auto;
width: 100%
}
.footer td b {
vertical-align:top;
color: #ccc2a0;
}
.footer td {
vertical-align:top;
color: #a8a8a8;
}
I have tried to get the space between the left side of the footer and the first table data to be the same as the space between the right side of the footer and the last table data however it always has a bigger gap on the right side.
Can anyone see a problem with the CSS I am using?
Thanks
EDIT:
Here is the code for trying to achieve this using divs:
<footer class="footer">
<div class="row" style="background-color:red;">
<div class="span12" style="background-color:orange;">
<div class="span4" id="leftFooter">
</div>
<div class="span4" id="middleFooter">
</div>
<div class="span4" id="rightFooter">
</div>
</div>
</div>
</footer>
The CSS simply colours the boxes so I can see what is going on and adds some height to the divs.
The grey box is the footer div, the red box is the row and the orange box is the span12. The rest are the 3 content divs of span4. Not sure why they don't stay on the same row.
I changed some of it and stripped all styling out (sorry), but your spacing should be fixed horizontally. You can apply whatever else you want styling wise. Also, I got rid of all the embedded tables because it was so cumbersome...I can adjust the vertical spacing if you want, but I just threw this together to give you an idea for horizontal spacing.
http://jsfiddle.net/YYZwY/1/
HTML:
<footer class="footer">
<table>
<td>
<div id="ContactUS" class="information">Contact Us</div>
<div id="Telephone" class="information">Tel: 01234 567897 </div>
<div id="email" class="information">Email: info#email.com</div>
</td>
<td>
<div class="links">Useful Links</div>
<div class="links">Contact Us</div>
<div class="links">About Us</div>
<div class="links">Copyright Information</div>
<div class="links">Terms & Conditions</div>
</td>
<td>
<div class="connect"><b>Connect With Us</b></div>
<div class="connect">Facebook</div>
<div class="connect">Twitter</div>
<div class="connect">Google Plus</div>
</td>
</footer>
CSS:
.links {
padding-left: 10px;
padding-right: 10px;
position: relative;
}
.connect {
padding-left: 10px;
padding-right: 10px;
position: relative;
}
.information {
padding-right: 10px;
}
CSS:
.span12 {
text-align: center;
}
This solution works if we don't mind the text alignment.
Result [CodePen] : http://codepen.io/loxaxs/pen/kilLG
A different solution:
CSS:
.span12 {
padding-left: 15%;
}
Result [CodePen] : http://codepen.io/loxaxs/pen/izIHq

CSS positioning problems (basic)

I'm designing a website and I need it to look something like this http://www.spookycraft.net/
excluding the slide show and javascript and such, I just need 4 separate clickable blocks in the middle of a webpage, I've tried to use margin:auto and then re-position it using margin-left and margin-bottom ect but when I use margin-bottom It just splits apart more and acts rather interestingly here's my current code keep in mind I also need it to look the same on a higher resolution screen which is why I was attempting to use margin:auto;
<!DOCTYPE HTML>
<html>
<head>
<table border="10px"; class="head">
<tr>
<td>
<img src="http://www3.alcatel-lucent.com/partners/hp/data-center-network-connect/images/Alliance_DCNC_700x200.jpg" > </>
</td>
<tr>
</table>
<style media="screen" type="text/css">
.tone{
margin:auto;
}
.ttwo{
margin:auto;
}
.tthree{
margin:auto;
}
.tfour{
margin:auto;
}
.head{
margin:auto;
}
</style>
</head>
<body>
<table border="5px"; class="tone">
<tr>
<td>
<img src="http://www.wilsoninfo.com/300x300.gif"> </>
</td>
</tr>
</table>
<table border="5px"; class="ttwo">
<tr>
<td>
<img src="http://www.wilsoninfo.com/300x300.gif"> </>
</td>
</tr>
</table>
<table border="5px" class="tthree">
<tr>
<td>
<img src="http://www.wilsoninfo.com/300x300.gif"> </>
</td>
</tr>
</table>
<table border="5px" class="tfour">
<tr>
<td>
<img src="http://www.wilsoninfo.com/300x300.gif"> </>
</td>
</tr>
</table>
</body>
</html>
Any help would be appreciated! I'll be working to find a answer to my problem, and when I do I'll update this thread.
Don't use tables, they are a no-no in my books. Tables should not be used for structure in a HTML page these days, they should only be used for presenting data in a tabular format. Just use <div>s with a master wrapper <div> around them. Something like this is perfect:
HTML:
<div class="container">
<div class="box spacing"><img src="http://www.wilsoninfo.com/300x300.gif" width="100%"></div>
<div class="box spacing"><img src="http://www.wilsoninfo.com/300x300.gif" width="100%"></div>
<div class="box spacing"><img src="http://www.wilsoninfo.com/300x300.gif" width="100%"></div>
<div class="box spacing"><img src="http://www.wilsoninfo.com/300x300.gif" width="100%"></div>
</div>
CSS:
body{
margin:0;
padding:0;
}
.container{
overflow:hidden;
width:450px;
margin:0px auto;
}
.box{
width:200px;
height:200px;
float:left;
background-color:#ccc;
margin-bottom:20px;
}
.spacing{
margin-right:20px;
}
Demo here: http://jsfiddle.net/aRSNh/172/
I'm not familiar with table design, but if you want to build it with div I have my code here
<div class="container">
<div class="box"><img src="http://www.wilsoninfo.com/300x300.gif"></div>
<div class="box"><img src="http://www.wilsoninfo.com/300x300.gif"></div>
<div class="box"><img src="http://www.wilsoninfo.com/300x300.gif"></div>
<div class="box"><img src="http://www.wilsoninfo.com/300x300.gif"></div>
</div>
with this css
.container {
width: 680px;
margin: 10px auto;
}
.box {
float: left;
margin: 20px;
}
A nice library for fast CSS development is Twitter bootstrap http://twitter.github.io/bootstrap/index.html
Here is a quick example using bootstrap:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Layout Demo</title>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap- combined.min.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid" style="margin: 100px 0px; 0px; 0px;">
<div class="row">
<div class="offset6 span3"> <img src="http://www.wilsoninfo.com/300x300.gif"> </> </div>
<div class="span3"> <img src="http://www.wilsoninfo.com/300x300.gif"> </> </div>
</div>
<br>
<div class="row">
<div class="offset6 span3"> <img src="http://www.wilsoninfo.com/300x300.gif"> </> </div>
<div class="span3"> <img src="http://www.wilsoninfo.com/300x300.gif"> </> </div>
</div>
</div>
</body>
</html>
Plunker: http://embed.plnkr.co/iKgsmZ/preview