Query results not properly displaying sometimes - twitter-bootstrap-3

Results show up like this
http://puu.sh/hZrVY/cbfe561492.jpg
How can I make it so that they show up in rows of 3 with no offsetting.
Code:
#foreach ($posts as $post)
<div class="col-md-4 portfolio-item">
<a href="/stories/{{ $post->slug }}#disqus_thread">
<img class="img-responsive" src="http://placehold.it/700x400" alt="">
</a>
<h3>
{{ str_limit($post->title, 34) }}
</h3>
<p>{{ str_limit($post->content) }}</p>
<em>({{ $post->published_at->format('M jS Y g:ia') }})</em>
</div>
#endforeach
CSS:
body {
background-image: url("http://www.ruschgaming.tv/img/bg.png");
background-attachment: fixed;
background-repeat: no-repeat;
}
.portfolio-item {
margin-bottom: 25px;
}
.container {
margin-top: 80px;
padding-top: 20px;
height: 100%;
background-color: #ffffff;
border-radius: 12px;
box-shadow: 2px 2px 5px grey;
}

Missing the rows tags:
#foreach ($posts as $key => $post)
#if(($key==0) || is_int($key/3))
<div class="row">
#endif
<div class="col-md-4 portfolio-item">
<a href="/stories/{{ $post->slug }}#disqus_thread">
<img class="img-responsive" src="http://placehold.it/700x400" alt="">
</a>
<h3>
{{ str_limit($post->title, 34) }}
</h3>
<p>{{ str_limit($post->content) }}</p>
<em>({{ $post->published_at->format('M jS Y g:ia') }})</em>
</div>
#if(is_int($key/3))
<div>
#endif
#endforeach

Related

Why are my columns overlapping vertically when I resize browser?

I'm practising bootstrap responsive web development, I've managed to make my webpage fairly responsive when I change the width however my middle columns overlap if I resize vertically. Here's the code:
<div class="container-fluid con">
<div class="row">
<div class="col-md-2 d-none d-md-block col1">
</div>
<div class="col-md-6 col2">
<p id="header-p">Full stack developer specialising in responsive website design and smooth user experience. Practical experience in project management, branding strategy, and creative direction; devoted to functional programming and information architecture</p>
<hr id="hr1">
<p id="header-tag">Web Developer - User Experience Designer - Graphic Artist
</p>
</div>
<div class="col-md-2 pic-col">
<img class="img-responsive rounded-circle img-thumbnail" src="#">
</div>
<div class="col-md-2 d-none d-md-block col1">
</div>
</div>
</div>
<div class="container-fluid con2">
<div class="row">
<div class="col-md-2 d-none d-md-block col1"></div>
<div class="col-md-8 port-col"><h2 id="portfolio-header">Portfolio</h2>
<hr id="hr2">
</div>
<div class="col-md-2 d-none d-md-block col1">
</div>
</div>
</div>
And the CSS:
#header-p{
margin-top: 10%;
text-align: center;
color: white;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size:20px;
}
#header-tag{
padding-top: 1rem;
text-align: center;
color: white;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size:20px;
}
.con{
margin: 4rem auto 2rem auto;
}
.col1, .col3{
border: 1px solid #bfbfbf;
background-color: #bfbfbf;
height: 100vh;
}
.col2{
background-color: #cccccc;
height: 60vh;
}
.pic-col{
background-color: #cccccc;
height: 60vh;
}
#portfolio-header{
text-align: center;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 60px;
letter-spacing: 5px;
/*line-height: 90px;*/
max-width: 100%;
color: #b3b3b3;
}
.port-col{
max-height: 100vh;
}
.con2{
margin: 2rem auto 2rem auto;!important
}
the full code is here if I'm missing anything https://codepen.io/Seaplush/pen/rKVLmX

search button to open search box in bootstrap navbar

I want to add search box to my navbar but not as the traditional way as appears in the picture , I want to add a search icon button in the navbar only and when user click on it the search box appears under the search icon .
How can i do this any one can help me please ?
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<div class="collapse navbar-collapse" >
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Contact US</li>
<li class="dropdown">
Who we are <b class="caret"></b>
<ul class="dropdown-menu">
<li>About</li>
<li> Mession</li>
<li> Vision</li>
<li class="divider"></li>
<li>Goals</li>
</ul>
</li>
<li>Publications</li>
<li>Media</li>
<li>Partners</li>
</ul>
There are lot of things on the net e.g https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_anim_search
Run below code:
<!DOCTYPE html>
<html>
<head>
<style>
input[type=text] {
width: 130px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url('https://www.w3schools.com/howto/searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}
input[type=text]:focus {
width: 100%;
}
</style>
</head>
<body>
<p>Animated search form:</p>
<form>
<input type="text" name="search" placeholder="Search..">
</form>
</body>
</html>
You can try these snippets.
Solutuion with CSS Only:
.hide
{
opacity: 0;
max-height: 0;
}
#trigger {
position: absolute;
left: -999em;
}
#container input[type="checkbox"]:checked + div
{
max-height: 99em;
opacity: 1;
height: auto;
overflow: hidden;
}
<div id="container">
<label for="trigger">click me for Search</label>
<input type="checkbox" id="trigger">
<div class="hide">
<form>
<input type="text" name="search" placeholder="Search..">
</form>
</div>
<div>
Solution with JS:
function myFunction() {
if (document.getElementById("form").style.display === "none") {
document.getElementById("form").style.display = "block";
} else {
document.getElementById("form").style.display = "none";
}
}
button {
width: 50px;
height: 50px;
}
<p>show and hide search</p>
<button onclick="myFunction()"></button>
<form id="form">
<input type="text" name="search" placeholder="Search..">
</form>

trying to use bootstrap 3 for nested columns but their being hidden

enter image description hereI'm trying to have an information panel with three different columns using bootstrap 3. I've nested the columns properly, I think, but the panels are hidden beneath the main row and I can't find a way to reveal it.
it's showing that the container is there, but you can't see it
<div class="row creative_line">
<div class="col-md-12">
<h2 class="text-center">Smart & Creative<br><p>This is why you will use it</p></h2>
</div>
<div class="col-md-12">
<div class="row">
<div class="col-md-4 multi">
<div class="img-circle">
</div>
</div>
<div class="col-md-4 ui">
<div class="img-circle">
</div>
</div>
<div class="col-md-4 design">
<div class="img-circle">
</div>
</div>
</div>
</div>
</div>
This is my current css
.creative_line {
background: yellow;
min-height: 300px;
color: $primary-color;
font-family: $font-stack;
}
.creative_line p {
color: $primary-color;
font-family: $font-stack2;
font-size: 35%;
margin-top: 10px;
}
h2 {
font-size: 40px;
}
.img-circle {
-webkit-clip-path: circle(50% at 50% 50%);
clip-path: circle(50% at 50% 50%);
background: red;
}
.multi,
.ui,
.design {
min-height: 300px;
color: blue;
z-index: 1;
}

Bootstrap column spanning 2 rows

Im trying to get a bootstrap column to span 2 rows. I have been been looking at How can I get a Bootstrap column to span multiple rows? and it doesnt seem to work in the context of my project.
Could someone tell me what I need to do in order to make the column on the right span 2 rows?
<div class="container" style="background-color: #fff">
<div class="row" style="background-color: #fff">
<div class="col-md-4">
<img src="public/img/index/Hola_Sevila.png" style="width:180px">
<h6>Hola Sevilla!</h6>
<p>I recently had the pleaseure and the privilege of travelling to the ...</p>
<p>Read More</p>
</div>
<div class="col-md-4">
<img src="public/img/index/Trans_helps_children.jpg" style="width:180px">
<h6>Translation helps children</h6>
<p>De La Salle Solidarieta Internatazionale ONLUS is a non-profit organisation that fundraises ...</p>
<p>Read More</p>
</div>
<div class="col-md-4 two_row_column">
<div class="index-b-right-1"></div>
<div class="index-b-right-1">
<h3>Videos</h3>
</div>
<div class="index-b-right-1">
<h3>Be a Friend</h3>
</div>
<div class="index-b-right-2">
<h4>You can show your appreciation and support future development by becoming a friend of the Rosetta</h4>
</div>
<div class="index-b-right-3">
<h3>Donate</h3>
</div>
<div class="index-b-right-1"></div>
</div>
</div>
CSS
.index-b-right-1 {
background-color: #000;
height: 40px;
border-bottom: 2px solid white;
color: #fff;
text-align: center;
padding-bottom: 10px;
}
.index-b-right-2 {
background-color: #000;
border-bottom: 2px solid white;
color: #fff;
text-align: center;
padding: 30px 40px 30px 40px;
}
.index-b-right-3 {
background-color: #000;
height: 40px;
border-bottom: 2px solid white;
text-align: center;
padding-bottom: 10px;
}
.index-b-right-3 a {
color: #CC9900;
}
I guess this is what you wanted to do?
Simple way i would explain it is you create the top most row, create the columns in the row, then in the other column, create another row which you then divide up into individual columns.
Hope it helps!
<div class="container" style="background-color: #fff">
<div class="row" style="background-color: #fff">
<div class="col-md-4">
<img src="public/img/index/Hola_Sevila.png" style="width:180px">
<h6>Hola Sevilla!</h6>
<p>I recently had the pleaseure and the privilege of travelling to the ...</p>
<p>Read More</p>
</div>
<div class="col-md-4">
<div class="row">
<div class="col-md-4">
<img src="public/img/index/Trans_helps_children.jpg" style="width:180px">
<h6>Translation helps children</h6>
<p>De La Salle Solidarieta Internatazionale ONLUS is a non-profit organisation that fundraises
...</p>
<p>Read More</p>
</div>
<div class="col-md-4 two_row_column">
<div class="index-b-right-1"></div>
<div class="index-b-right-1">
<h3>Videos</h3>
</div>
<div class="index-b-right-1">
<h3>Be a Friend</h3>
</div>
<div class="index-b-right-2">
<h4>You can show your appreciation and support future development by becoming a friend of the
Rosetta</h4>
</div>
<div class="index-b-right-3">
<h3>Donate</h3>
</div>
<div class="index-b-right-1"></div>
</div>
</div>
</div>
</div>

Getting Bootstrap 3 Tab Panes to Work with TreeView

I am trying to get the TreeView from BootSnipp here: 1 to work with Bootstrap 3 tabs.
It works as expected initially, but breaks down after a few clicks, then responding/not responding arbitrarily. Here's the html+js+css I am working with:
// ***************** BEGIN TREE JS *****************
$.fn.extend({
treed: function() {
return this.each(function() {
//initialize each of the top levels
var tree = $(this);
tree.addClass("tree");
tree.find('li').has("ul").each(function() {
var branch = $(this); //li with children ul
branch.prepend("<i class='indicator glyphicon glyphicon-plus-sign'></i>");
branch.addClass('branch');
branch.on('click', function(e) {
if (this == e.target) {
var icon = $(this).children('i:first');
icon.toggleClass("glyphicon-minus-sign glyphicon-plus-sign");
$(this).children().children().toggle();
}
})
branch.children().children().toggle();
});
//fire event from the dynamically added icon
$('.branch .indicator').on('click', function() {
$(this).closest('li').click();
});
//fire event to open branch if the li contains an anchor instead of text
$('.branch a').on('click', function(e) {
$(this).closest('li').click();
e.preventDefault();
});
//fire event to open branch if the li contains a button instead of text
$('.branch button').on('click', function(e) {
$(this).closest('li').click();
e.preventDefault();
});
});
}
});
$('.tree').treed();
//***************** END TREE JS *****************
/*BEGIN TREE CSS*/
.tree,
.tree ul {
margin: 0;
padding: 0;
list-style: none
}
.tree ul {
margin-left: 1em;
position: relative
}
.tree ul ul {
margin-left: .5em
}
.tree ul:before {
content: "";
display: block;
width: 0;
position: absolute;
top: 0;
bottom: 0;
left: 0;
border-left: 1px solid
}
.tree li {
margin: 0;
padding: 0 1em;
line-height: 2em;
color: #369;
font-weight: 700;
position: relative
}
.tree ul li:before {
content: "";
display: block;
width: 10px;
height: 0;
border-top: 1px solid;
margin-top: -1px;
position: absolute;
top: 1em;
left: 0
}
.tree ul li:last-child:before {
background: #fff;
height: auto;
top: 1em;
bottom: 0
}
.indicator {
margin-right: 5px;
}
.tree li a {
text-decoration: none;
color: #369;
}
.tree li button,
.tree li button:active,
.tree li button:focus {
text-decoration: none;
color: #369;
border: none;
background: transparent;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
outline: 0;
}
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="container">
<div class="row">
<div class="col-xs-7">
<ul id="tabs" class="tree">
<li>Continent Overview
</li>
<li>Countries
<ul>
<li>Country 1
<ul>
<li>Country Overview
</li>
</ul>
</li>
<li>Country 2
<ul>
<li>Country Overview
</li>
<li>Cities
<ul>
<li>City P
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>Cities
<ul>
<li>
City A
<ul>
<li>Overview
</li>
</ul>
</li>
<li>
City B
<ul>
<li>Overview
<li>Neighborhoods
<ul>
<li>Neighborhood X
</li>
</ul>
</li>
</li>
</ul>
</li>
</ul>
</li>
<li>Neighborhoods
<ul>
<li>Neighborhood T
</li>
</ul>
</li>
</ul>
</div>
<div class="col-xs-5">
<div class="tabbable" id="tabbable-proj">
<div class="tab-content main-tab-content">
<div class="tab-pane fade in active" id="panel-continent-overview">
<strong>Continent Details</strong>
</div>
<div class="tab-pane fade" id="panel-country-9400470e-fa49-46ea-b587-2ceb108600c0">
<strong>Country Details</strong>
</div>
<div class="tab-pane fade" id="panel-country-45f97844-9773-4059-bafd-a2782fc06db1">
<strong>Country Details</strong>
</div>
<div class="tab-pane fade" id="panel-city-2120d7aa-2b93-4d0d-a42b-8c6fedc9333a">
<strong>City Details</strong>
</div>
<div class="tab-pane fade" id="panel-neighborhood-babea547-cfb6-4e12-8c4a-bbbb25068d8a">
<strong>Neighborhood Details</strong>
</div>
<div class="tab-pane fade" id="panel-city-b4a991ce-80ef-4406-b1d2-9892c0d93d18">
<strong>City Details</strong>
</div>
<div class="tab-pane fade" id="panel-city-2e6f1227-66d0-4061-9243-bf6cf4feaabd">
<strong>City Details</strong>
</div>
<div class="tab-pane fade" id="panel-neighborhood-f3fd5e2f-583d-4ccb-b163-03e118896f71">
<strong>Neighborhood Details</strong>
</div>
<div class="tab-pane fade" id="panel-neighborhood-319d56ac-286f-4afa-af42-5ec74bbcac19">
<strong>Neighborhood Details</strong>
</div>
</div>
</div>
</div>
</div>
</div>
I am totally at a loss as to what is causing the problem. Could someone please help me with flushing out the bug?
Okay, I will attempt it myself.
It was not working because Bootstrap expects the tabs to be one flat ul - and I had multiple nested uls.
I got it working by
dissociating the tree from the tabbable;
creating a hidden flat ul for tabs; and
hooking the relevant tree anchor clicks to manually call $('...).tab('show') on the respective tab.
I have also discovered that using this strategy, I can call up my tabs from anywhere on the page - e.g. from a breadcrumb or a random anchor.
Now I know my question was too noobish for most people out there to tackle - the html itself was all over the place.
The answer I have been able to work out looks slightly hackish. Will somebody at least comment as to how good or bad it is? Like, will it incur search engine penalties for hiding the ul? What will the implications for accessibility be - especially as I have removed text from the anchor tags?
Or should I post one or more new questions to solicit this kind of feedback?
Cheers
// ***************** BEGIN TREE JS *****************
$.fn.extend({
treed: function() {
return this.each(function() {
//initialize each of the top levels
var tree = $(this);
tree.addClass("tree");
tree.find('li').has("ul").each(function() {
var branch = $(this); //li with children ul
branch.prepend("<i class='indicator glyphicon glyphicon-plus-sign'></i>");
branch.addClass('branch');
branch.on('click', function(e) {
if (this == e.target) {
var icon = $(this).children('i:first');
icon.toggleClass("glyphicon-minus-sign glyphicon-plus-sign");
$(this).children().children().toggle();
}
})
branch.children().children().toggle();
});
//fire event from the dynamically added icon
$('.branch .indicator').on('click', function() {
$(this).closest('li').click();
});
//fire event to open branch if the li contains an anchor instead of text
$('.branch a').on('click', function(e) {
$(this).closest('li').click();
e.preventDefault();
});
//fire event to open branch if the li contains a button instead of text
$('.branch button').on('click', function(e) {
$(this).closest('li').click();
e.preventDefault();
});
});
}
});
$('.tree').treed();
//***************** END TREE JS *****************
$(document).ready(function() {
$("a.tree-link").on('click', function (event) {
var hrefTab = $(this).attr('href');
$('#hidden-tabs a[href='+hrefTab+']').tab('show');
});
});
#hidden-tabs{
height: 0px;
list-style-type: none;
padding:0;
margin:0;
}
#hidden-tabs{
height: 0px;
list-style-type: none;
padding:0;
margin:0;
}
#hidden-tabs li{
height: 0px;
padding:0;
margin:0;
}
#hidden-tabs li a{
height: 0px;
padding:0;
margin:0;
}
/*BEGIN TREE CSS*/
.tree,
.tree ul {
margin: 0;
padding: 0;
list-style: none
}
.tree ul {
margin-left: 1em;
position: relative
}
.tree ul ul {
margin-left: .5em
}
.tree ul:before {
content: "";
display: block;
width: 0;
position: absolute;
top: 0;
bottom: 0;
left: 0;
border-left: 1px solid
}
.tree li {
margin: 0;
padding: 0 1em;
line-height: 2em;
color: #369;
font-weight: 700;
position: relative
}
.tree ul li:before {
content: "";
display: block;
width: 10px;
height: 0;
border-top: 1px solid;
margin-top: -1px;
position: absolute;
top: 1em;
left: 0
}
.tree ul li:last-child:before {
background: #fff;
height: auto;
top: 1em;
bottom: 0
}
.indicator {
margin-right: 5px;
}
.tree li a {
text-decoration: none;
color: #369;
}
.tree li button,
.tree li button:active,
.tree li button:focus {
text-decoration: none;
color: #369;
border: none;
background: transparent;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
outline: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-xs-7">
<ul class="tree">
<li>Continent Overview
</li>
<li>Countries
<ul>
<li>Country 1
<ul>
<li>Country Overview
</li>
</ul>
</li>
<li>Country 2
<ul>
<li>Country Overview
</li>
<li>Cities
<ul>
<li>City P
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>Cities
<ul>
<li>
City A
<ul>
<li>Overview
</li>
</ul>
</li>
<li>
City B
<ul>
<li>Overview
<li>Neighborhoods
<ul>
<li>Neighborhood X
</li>
</ul>
</li>
</li>
</ul>
</li>
</ul>
</li>
<li>Neighborhoods
<ul>
<li>Neighborhood T
</li>
</ul>
</li>
</ul>
</div>
<div class="col-xs-5">
<div class="tabbable" id="tabbable-proj">
<ul id="hidden-tabs" role="tablist" aria-expanded="false">
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
</ul>
<div class="tab-content main-tab-content">
<div class="tab-pane fade in active" id="panel-continent-overview">
<strong>Continent Details</strong>
</div>
<div class="tab-pane fade" id="panel-country-9400470e-fa49-46ea-b587-2ceb108600c0">
<strong>Country 1 Details</strong>
</div>
<div class="tab-pane fade" id="panel-country-45f97844-9773-4059-bafd-a2782fc06db1">
<strong>Country 2 Details</strong>
</div>
<div class="tab-pane fade" id="panel-city-2120d7aa-2b93-4d0d-a42b-8c6fedc9333a">
<strong>City P Details</strong>
</div>
<div class="tab-pane fade" id="panel-neighborhood-babea547-cfb6-4e12-8c4a-bbbb25068d8a">
<strong>Neighborhood Details</strong>
</div>
<div class="tab-pane fade" id="panel-city-b4a991ce-80ef-4406-b1d2-9892c0d93d18">
<strong>City A Details</strong>
</div>
<div class="tab-pane fade" id="panel-city-2e6f1227-66d0-4061-9243-bf6cf4feaabd">
<strong>City B Details</strong>
</div>
<div class="tab-pane fade" id="panel-neighborhood-f3fd5e2f-583d-4ccb-b163-03e118896f71">
<strong>Neighborhood X Details</strong>
</div>
<div class="tab-pane fade" id="panel-neighborhood-319d56ac-286f-4afa-af42-5ec74bbcac19">
<strong>Neighborhood T Details</strong>
</div>
</div>
</div>
</div>
</div>
</div>