How to add cols on top of image in bootstrap - html

Please i am new to bootstrap. Recently lean the grids etc. I am trying to add controls like a table or on top of an image exactly like the search and the testimonial one here . Just from the example, i dont want by whole site on top the image. Just one row.
<div class='container-fluid'>
<div class='row' style='position:absolute; z-index=-1'>
<img src='images/banner.jpg' alt='Blast off with Bootstrap' />
</div>
<!-- My other controls goes here, example my table etc. -->
</div>
<div class='container'>
<!-- I dont like what ever is in this container to display on top the image above.-->
</div>
When i run my code , everything displays on the image including the second container. Please how do i archive that? Any help is highly appreciated.

check out this code i had provided the working example
<div class='container-fluid'>
<div class='row banner'>
<img src='http://images.visitcanberra.com.au/images/canberra_hero_image.jpg' alt='Blast off with Bootstrap' />
<div class="table-block">
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
</table>
</div>
</div>
<!-- My other controls goes here, example my table etc. -->
</div>
<div class='container'>
<!-- I dont like what ever is in this container to display on top the image above.-->
</div>
CSS code :
img{
width:100%;
height:200px;
}
table, td, th {
border: 1px solid #111;
}
table {
width: 400px;
}
.table-block{
position:absolute;
top:25px;
left:25px;
}
.banner{position:relative;}
working example

Related

Overflowing layout with flexbox and bootstrap3 columns causing undesired page width increase

I have a layout making use of twitter-bootstrap-3 columns and flexbox.
At a highlevel, the layout I am trying to achieve is like this:
The toolbar and the rest of the content are flexed next to each other (dashed boxes are the children of the flex):
The non-toolbar sections (the green, blue and yellow boxes) are one bootstrap3 row, with three columns (columns are dashed boxes). On large screens the layout should be like the image (meta + main content is col-md-7, secondary #1 is col-md-5, secondary #2 is col-md-12), but defaulting to separate rows on small screens (all col-sm-12):
Finally, the meta and main content (the green and blue boxes) are flexed next to each other (dashed boxes are the children of the flex):
The tricky part is that the main content (the blue section) can get quite wide and must scroll horizontally. The issue I am running into is that as the overflowing content section gets larger, it seems to push the screen artificially wide and escape the boundaries of the bootstrap column.
Here is a simplified example showcasing the issue. (You might have to click "Full page" link to see the overflow issue.)
Is there any way to get around this issue?
.flex {
display: flex;
}
.flex-variable {
flex: 1 1 auto;
/*flex:1;*/
}
.w-100 {
width: 100%;
}
.overflowable-h {
overflow-x: auto;
}
div {
border: 1px gray solid;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div class="container-fluid">
<h1>overflowing content</h1>
<div class="flex">
<div>toolbar</div>
<div class="flex-variable">
<div class="row">
<div class="col-md-7">
<div class="flex">
<div class="text-nowrap">
<table>
<tr>
<td>metadata</td>
<td>metadata</td>
</tr>
<tr>
<td>metadata</td>
<td>metadata</td>
</tr>
</table>
</div>
<div class="flex-variable w-100 text-nowrap overflowable-h">
<table>
<tr>
<td>content-content-content-content-content-content-content-content-content-content-content-content-content-content-content-content-content-content-content-content-content-content-content-content-content-content-content</td>
</tr>
<tr>
<td>content-content-content-content-content-content-content-content-content</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-md-5">
<div>secondary-secondary-secondary-secondary-secondary-secondary</div>
</div>
<div class="col-md-12">secondary-secondary-secondary-secondary-secondary-secondary-secondary-secondary-secondary</div>
</div>
</div>
</div>
<h1>no overflowing content</h1>
<div class="flex">
<div>toolbar</div>
<div class="flex-variable">
<div class="row">
<div class="col-md-7">
<div class="flex">
<div class="text-nowrap">
<table>
<tr>
<td>metadata</td>
<td>metadata</td>
</tr>
<tr>
<td>metadata</td>
<td>metadata</td>
</tr>
</table>
</div>
<div class="flex-variable w-100 text-nowrap overflowable-h">
<table>
<tr>
<td>content-content</td>
</tr>
<tr>
<td>content-content-content</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-md-5">
<div>secondary-secondary-secondary-secondary-secondary-secondary</div>
</div>
<div class="col-md-12">secondary-secondary-secondary-secondary-secondary-secondary-secondary-secondary-secondary</div>
</div>
</div>
</div>
</div>
</body>
</html>
if i understand correct, try this:
add and modify your css like below: (toolbar can have any fixed width px/rem/vw/percent and Your flex-variable should calc available width based on toolbar width)
#toolbar{width:200px;}
.flex-variable {
flex: 1 1 auto;
width: calc(100% - 200px);
}
and add id to toolbard div
<div id="toolbar">toolbar</div>
You can achive this in many ways, but your container should have some width to not overflow.

Is it possible to layout span/div in this way?

Im generating a table in php, and would like it in the top left of the screen.
The table varies slightly in width so directly to the right of it should go two blocks of text (text1, text2) and a third text (text3) which floats in the topmost right of the screen.
Below the three texts should be text4.
Requirements:
Text1 needs to always be to the right of the table.
text4 always needs to be below the top 3 texts.
I uploaded an image with the span/div/table/text and have literally been trying to arrange these for about 1.5 hours now. it seems like it should be really simple but im struggling with my requirements and one of them always seems to misalign. (all the 'texts' are just pieces of html text (not <input type=text or <textarea>)
Edit: Thankyou, is it possible without using libraries or bootstrap?
If you don't like using <table> tags for layouts, and don't like an extra large dependency to your project (like bootstrap), one could go for the following option:
<div class="table">
Table
</div>
<div class="text-container">
<div class="text1">
Text1
</div>
<div class="text2">
Text2
</div>
<div class="text3">
Text3
</div>
<div class="text4">
Text4
</div>
</div>
It is crucial that the display type of .table, .text-container and .text{1,2,3} are all display: inline-block;. This will make them inline. However, to force wrapping of .text4, this will still have to be display: block;.
https://jsfiddle.net/nnLofpL1/
Like hjardine uses in his example: it may also be a good idea to look to the clear property.
However it is not the nicest solution, the classic "table in table" does the job:
<table>
<tr>
<td>
<table>
<tr>
<td>PHP generated data</td>
</tr>
</table>
</td>
<td>
<table>
<tr style="height: 60px;">
<td>Text 1</td>
<td style="padding-left: 100px;">Text 2</td>
<td style="width: 200px; text-align: right;">Text 3</td>
</tr>
<tr style="height: 60px;">
<td colspan="3">Text 4</td>
</tr>
</table>
</td>
</tr>
</table>
https://jsfiddle.net/jrrfbqfk/
I can see you don't want to use bootstrap so i have updated an answer so that you don't have to use a table either, exact same output but without the problems of using a table for output.
.div1{float:left;width:40%;border:1px solid #000;min-height:200px;}
.div2{float:right;width:58%;border:1px solid #000;min-height:200px;}
.row1{min-height:100px;}
.sp1{float:left;width:30%;padding:4px;border:1px solid #000;min-height:60px;}
.sp2{float:left;width:30%;padding:4px;border:1px solid #000;min-height:60px;}
.sp3{float:right;width:30%;text-align:right;padding:4px;border:1px solid #000;min-height:60px;}
.divRow{width:100%;border: 1px solid #000;}
<div>
<div class="div1">
<div class="divRow">1</div>
<div class="divRow">2</div>
<div class="divRow">3</div>
<div class="divRow">4</div>
<div class="divRow">5</div>
<div class="divRow">6</div>
</div>
<div class="div2">
<div>
<div class="row1">
<div class="sp1">1</div>
<div class="sp2">2</div>
<div class="sp3">3</div>
<div style="clear:both;"></div>
</div>
<div class="row2" style="border:1px solid #000;min-height:40px;">
sadsadsad
</div>
</div>
</div>
<div style="clear:both;">
</div>
</div>
An easy solution to laying out a page so that things are where you want them is using bootstrap, because of the grid layout in bootstrap you can keep things in the same relative positions no matter what the size of the page is.
For what you want to do i think it would benefit you greatly.
EXAMPLE
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<div class="Container">
<div class="row">
<div class="col-xs-2">
Top left
</div>
<div class="col-xs-2 col-xs-offset-8">
Top right
</div>
</div>
</div>
This is a link to Bootstrap which is well worth learning IMHO!

Table not getting resized inside a div on resizing the div

I have a table in my jsp inside a div which is resizeable.
When I'm resizing the div, I'm not able to resize the height of table inside where as width of table is getting resized. Following is my snippet. Please check once.
<div id="id" style="height:350px; width250px;" class="control">
<div id="fifth_heading" class="heading_control">
<i class="fa2 fa-fifth"></i>
<p><%=entry1.getDivdescription() %></p>
<div class="button_right_second">
<i class="fa3 fa-second3" id="<%=entry1.getDivid() %>"></i>
</div>
</div>
<div class="fifth_dropdown">
<div class="table_data" id="table_second">
<table id="example3" style="height:auto;"class="display" border="0" cellspacing="0" cellpadding="0">
<!-- the below tr prints the dates -->
<tbody>
<tr id="line1">
<td>
<span id="header_title">Your Current Lead Time</span>
</td>
</tr>
<tr id="line2">
<td>
<span id="value">alignvalue</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
div.table_data{margin-left:2px;margin-right:10px;margin-top:5px;overflow:auto;}
#table_second::-webkit-scrollbar{
width:10px;
background-color:#cccccc;
}
#table_second::-webkit-scrollbar-thumb{
background-color:rgb(78, 82, 93);
border-radius:10px;
}
#table_second::-webkit-scrollbar-thumb:hover{
background-color:rgb(78, 82, 93);
border:1px solid #333333;
}
#table_second::-webkit-scrollbar-thumb:active{
background-color:rgb(78, 82, 93);
border:1px solid #333333;
}
Try setting the height of your table to 100% and explicitly setting the div's height.
Answer as per this post: link
Not sure which <div> you want to resize but you can try one of these...
If you want to resize the <div id="id" ... class="control"> to make your <table> resized, try to add the height property in your div.table_data with % percent unit.
If you like to resize your <div> and <table>, you must set the height your <div> with class control, div.table_data and your <table> to 100% or any value (from 0-100) with % percent unit.
My code snippet after doing that...
CSS
div.table_data
{
margin-left:2px;
margin-right:10px;
margin-top:5px;
overflow:auto;
height:70%;
background-color:#ccffcc;
}
(Excluded the -webkit-scrollbar)
HTML
<div id="id" style="height:100%; width250px;background-color:#ff9999;" class="control">
<div id="fifth_heading" class="heading_control">
<i class="fa2 fa-fifth"></i>
<p>dddddddd</p>
<div class="button_right_second">
<i class="fa3 fa-second3" id="ddd"></i>
</div>
</div>
<div class="fifth_dropdown">
<div class="table_data" id="table_second">
<table id="example3" style="height:100%;" class="display" border="1" cellspacing="0" cellpadding="0">
<!-- the below tr prints the dates -->
<tbody>
<tr id="line1">
<td>
<span id="header_title">Your Current Lead Time</span>
</td>
</tr>
<tr id="line2">
<td>
<span id="value">alignvalue</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
This snippet can make the two <div> and your <table> will be re-sized when the window is re-sized.
If you don't like that your <table> will be too small if the size of your window is too small, you can use the min-height CSS property. For bigger sizes, use max-height.

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

Replicate a table with div-css

I have a website wallz.moon.pk, it's a wallpaper collection, on the gallery where I show thumbnails I have created a mouse over effect that for mouse a semi transparent strip is shown over the thumbnail so that user can select an appropriate answer..
I am not very good with DIVs so I put in a table to create the effect I wanted, check it out here, I have used the following code:
<div id="i551" class="actions">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center" colspan="2"><h2>Water Bubbles</h2></td>
</tr>
<tr>
<td width="50%">
Open Here
</td>
<td width="50%">
<a href="Water+Bubbles.html" class="acthuns" target="_blank">
+ New Tab </a>
</td>
</tr>
</table>
</div>
My question is how to convert the above Table and used DIVs & CSS styling to get the same effect....
Here is a simple approach:
http://jsfiddle.net/tNms9/3/
HTML
<div id="i551" class="actions">
<div class="row">
<h2>Water Bubbles</h2>
</div>
<div class="row">
<div class="cell">
Open Here
</div>
<div class="cell">
<a href="Water+Bubbles.html" class="acthuns" target="_blank">
+ New Tab </a>
</div>
</div>
</div>​
CSS
.actions{ width:400px; }
.row { width:100%; overflow:hidden; background:lime; }
.cell {width:45%; padding:10px; float:left; background:orange; }​
In CSS 2.1, the display property have Table model values which allows you to set the display of a element to each <table> known element : https://developer.mozilla.org/en-US/docs/CSS/display#Values
PS : It doesn't work on IE7-.
The provided code will produces the first row of images. You can mess with the percentages to get the white space you want, but here is the basic idea:
CSS:
.tile-container {
width:100%;
margin-left:-2%; /* offsets the first column of tiles */
}
.tile {
float:left;
width:23%;
margin-left:2%;
margin-bottom:2%;
}
HTML:
<div class="tile-container">
<div class="tile>
<!-- Image + other markup goes here -->
<div>
<div class="tile>
<!-- Image + other markup goes here -->
<div>
<div class="tile>
<!-- Image + other markup goes here -->
<div>
<div class="tile>
<!-- Image + other markup goes here -->
<div>
</div>