Is there a bootstrap class that will fill however many columns have not already been taken?
for example i have this div tag that might be there and it might not if it isnt i want the second div to take up 12 columns, but if it is there only take up 8 columns. like this
<div class="row">
<?php if(something){ ?>
<div class="col-md-4">
<div> </div>
</div>
<?php } ?>
<div class="col-md-fill">
<div> </div>
</div>
</div>
other than using
<div class="col-md-<?php
if($count > 5){
echo "8";
} else {
echo '12';
}
?>">
Sometimes I try something very stupid, but this time my stupidity surprises me...
I've seen than if we append to a div.row a div without any class, this no-class div fills herself the empty space....
Fiddle : http://jsfiddle.net/bhgme789/1/
HTML:
<div class="container">
<div class="row">
<div class="col-md-4 bleu">bleu</div>
<div class="rouge">rouge</div>
</div>
<div class="row">
<div class="col-md-1 bleu">bleu</div>
<div class="rouge">rouge</div>
</div>
<div class="row">
<div class="col-md-9 bleu">bleu</div>
<div class="rouge">rouge</div>
</div>
</div>
You're on the right track. Just finish your if statement with an else. One way, it uses a 4 and 8, the other it uses a 12 and takes up the whole row.
<div class="row">
<?php if(something){ ?>
<div class="col-md-4">
<div> </div>
</div>
<div class="col-md-8">
<div> </div>
</div>
<?php } else { ?>
<div class="col-md-12">
<div> </div>
</div>
<?php } ?>
</div>
When using Bootstrap v4 and v5 you should make use of the 'equal-width' column class col:
.col{
flex: 1 0 0%;
}
I needed this for edge cases where the last column was pushed to the next line caused by rounding errors when the browser calculates the with in pixes using the percentage based column styles. So in some situations my last column with col-2 was pushed down, using just col solved it.
A fiddle like the earlier given example with blue and red cells: http://jsfiddle.net/o14qh386/
I would do it like that, to keep code dry
<div class="row">
<div class="<?php if($something){echo 'col-md-push-4 col-md-8'}else{echo 'col-md-12'}">
</div>
</div>
I now noticed that you might want to put something if is in 4. in this case this might not be useful. If you just want to fulfil the space this is your solution
Related
I created a blog category from the menu. In Joomla 4 -> In Blog Layout -> Columns ، I can give a value to the column, but if we increase the value by one, the displayed contents are not balanced. And the "" did not close properly. After a general search, I realized that the contents are arranged as follows :
HTML :
<div class="blog-items">
<div class="blog-item">
<div class="content">1</div>
<div class="blog-item">
<div class="content">2</div>
</div>
<div class="blog-item">
<div class="content">3</div>
<div class="blog-item">
<div class="content">4</div>
<div class="blog-item">
<div class="content">5</div>
</div>
<div class="blog-item">
<div class="content">6</div>
</div>
<div class="blog-item">
<div class="content">7</div>
</div>
</div>
</div>
</div>
</div>
HTML The right way to be :
<div class="blog-items">
<div class="blog-item"><div class="content">1</div></div>
<div class="blog-item"><div class="content">2</div></div>
<div class="blog-item"><div class="content">3</div></div>
<div class="blog-item"><div class="content">4</div></div>
<div class="blog-item"><div class="content">5</div></div>
<div class="blog-item"><div class="content">6</div></div>
<div class="blog-item"><div class="content">7</div></div>
</div>
Note: When I disable "loadTemplate", the loop is displayed correctly and the divisions are closed correctly.
I also checked the information inside the "$this->loadTemplate('item')" but found no problem.
PHP :
<div class="blog-items">
<?php foreach ($this->intro_items as $key => &$item) : ?>
<div class="blog-item">
<?php
$this->item = & $item;
echo $this->loadTemplate('item'); //Included <div class="content">value</div>
?>
</div>
<?php endforeach; ?>
</div>
it's true,fixed.
All content had a tag before page break,
You cannot insert it inside a div. The closing tag will be missing. Close the tag before inserting Read More.
Little did I know that using before page break can be so destructive, and I've been looking for problems with PHP code for about a week now.
I am generating new cards with PHP code, but they do not listen to the grid of bootstrap 4.
Raw html code works fine and displays them like they should be.
<div class="container-fluid padding">
<div class="row padding">
<?php foreach ($contacts as $contact): ?>
<div class="col-sm-12 col-md-4">
<div class="card">
<?php echo '<img class="card-img-top" src="data:image/png;base64,'.base64_encode( $contact['horse_image'] ).'"/>'; ?>
<div class="card-body">
<h4 class="card-title"><?=$contact['horse_name']?></h4>
<p class="card-text"><?=$contact['short']?></p>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<hr class="my-4">
</div>
This is the code for generated cards from database, it works just fine but bootstrap is not applied on that so it looks very bad like that but it should be looking like that
Is there a way to apply bootstrap after the cards are generated?
Sorry, can't comment yet because of the reputation of 50 :D
In your foreach block is one closing div tag too much ;)
I've used cycle2 a number of times, but am trying to do something a little different with HTML than what I normally would do. Please see my code below. Am I doing the right thing with the "data-cycle-slides" value?
<div class="cycle-slideshow"
data-cycle-fx="scrollHorz"
data-cycle-speed="700"
data-cycle-timeout="3600"
data-cycle-slides="> section > div.is-left">
<section id="is-top">
<?php foreach ($array as $key => $value) { ?>
<div class="is-left ic">
<div class="in">
<!-- more html -->
</div>
</div>
<?php } ?>
<div id="other-stuff">
<p>yo!</p>
</div>
<div id="more-stuff">
<p>hey!</p>
</div>
</section>
</div>
It looks ok to me, and when I view the page source, nothing seems amiss. But when I have a look in Firebug or the Firefox developer tools, things appear to be out of order. If there are two items in the array, I see something like this...
<div class="cycle-slideshow" data-cycle-fx="scrollHorz" <!-- et cetera -- >>
<div class="is-left ic">
<div class="in">
<!-- more html -->
</div>
</div>
<section id="is-top">
<div id="other-stuff">
<p>yo!</p>
</div>
<div id="more-stuff">
<p>hey!</p>
</div>
</section>
<div class="is-left ic">
<div class="in">
<!-- more html -->
</div>
</div>
<div class="is-left ic">
<div class="in">
<!-- more html -->
</div>
</div>
</div>
Note that items that should appear inside of #is-top are appearing outside of that section. Also, there are somehow three .is-left items in firebug, when there should be two.
I don't know if this is a case where firebug is making a mistake and causing me some confusion, or if I'm taking the wrong approach with cycle2.
My program is fetching 3 customer records from database in PHP language.i want to show the return result from database in a bootstrap
grid view like 3 col of col-sm-4 in one row. Right now, it shows all
the result in one vertical line.Next thing i want is if have more
records, then the next record should show in next line and allow only
3 records in one line every time i fetch records from database.
Looking for the solution.
<div class="container-fluid" style="margin:0px auto;height:auto;border:1px solid yellow;">
#foreach($reviews as $review)
<div class="row">
<div class="col-sm-12">
<div class="col-sm-4">
<div>name is:- {{$review->name}}</div>
<div>course is:-{{$review->course}}</div>
<div>designation is:-{{$review->designation}}</div>
<div>company is:-{{$review->company}}</div>
<div>comments:-{{$review->comments}} </div>
<div>status:{{$review->status}} </div>
<div>priority:{{$review->priority}}</div>
<div>review date:-{{$review->review_date}}</div>
<?php
$image =stripslashes($review->image);
?>
<div>images:<img src='{{asset("$image")}}'></div>
</div>
</div>
</div>
#endforeach
</div>
You could do something like this
<div class="row">
<div class="col-sm-4">data 1</div>
<div class="col-sm-4">data 2</div>
<div class="col-sm-4">data 3</div>
<div class="col-sm-4">data 4</div>
<div class="col-sm-4">data 5</div>
<div class="col-sm-4">data 6</div>
.
.
.
.
.
</div>
This will add 3 columns in each row for N number of data automatically!
Move the row outside of the loop as shown below
Also, I'm not sure why you have a col-sm-12 and a col-sm-4? I'm sure that will confuse things
<div class="row">
#foreach($reviews as $review)
<!--<div class="col-sm-12"> -->
<div class="col-sm-4">
<div>name is:- {{$review->name}}</div>
<div>course is:-{{$review->course}}</div>
<div>designation is:-{{$review->designation}}</div>
<div>company is:-{{$review->company}}</div>
<div>comments:-{{$review->comments}} </div>
<div>status:{{$review->status}} </div>
<div>priority:{{$review->priority}}</div>
<div>review date:-{{$review->review_date}}</div>
<?php
$image =stripslashes($review->image);
?>
<div>images:<img src='{{asset("$image")}}'></div>
</div>
<!-- </div> -->
#endforeach
</div>
Unfortunately I won't be able to describe my issue without a visit to my site. DadGab.com.
I have a 'featured slider' col-md-8 with a sidebar to the right. It appears there is some padding or spacing set somewhere and I am unable to find it. I've checked all theme files, style.php. All I am trying to do is move the sidebar on the right side to the top of the page. The empty space did used to be a col-md-4 container which the coding has since been removed.
If I remove the featured slider code from the main page, the 'latest' posts as well as the menu do move to the top of the screen without the padding issue.
Any help would be greatly appreciated.
you have the following structure
<div class="col-md-8"></div>
<div class="clear"></div>
<div class="col-md-8"></div>
<div class="col-md-4"></div>
if i understand you corectly you should have
<div class="col-md-8"></div>
<div class="col-md-4"></div>
so join the code from both .col-md-8 containers, remove the div with class "clear" and it should be OK. This is all done in template homepage.php
You have some problems in your layout logic. You need to think about the way columns and rows work.
You should have a left column (col-md-8) and a sidebar column (col-md-4) and they should be adjacent. The left column should contain ALL of the left content.
Here's what you have:
<div class="row">
<div class="col-md-8">
<!-- featured -->
</div>
<div class="clear"><!-- SEPARATION --></div>
<div class="col-md-8">
<!-- REAST OF LEFT COLUMN -->
</div>
<div class="col-md-4">
<!--
SIDEBAR
You want this next to the left column.
But it's not adjacent!
-->
</div>
</div>
Here's what you want
<div class="row">
<div class="col-md-8">
<!-- FEATURED -->
<!-- REST OF LEFT COLUMN -->
</div>
<div class="col-md-4">
<!-- RIGHT SIDEBAR -->
</div>
</div>
Your current scenario is following
<div class="col-md-8">
featured slider
</div>
<div class="col-md-8">
content
</div>
<div class="col-md-4">
sidebar
</div>
Change it to following
<div class="col-md-8">
featured slider
content
</div>
<div class="col-md-4">
sidebar
</div>
Please let me know if issue is still there :)
After your div "col-md-8" is coming a clearfix. Just creat a "col-md-4" after "col-md-8".
I already tested here, just do it.
Inside the tags
<div class="container"><div class="row">
rearrange the order, from:
<div class="col-md-8"> ... </div>
<div class="clear"></div>
<div class="col-md-8"> ... </div>
<div class="col-md-4"> ... </div>
to:
<div class="col-md-8"> ... </div>
<div class="col-md-4"> ... </div>
<div class="clear"></div>
<div class="col-md-8"> ... </div>
In addition, consider if you really want to keep the div that clears out your floats:
<div class="clear"></div>
If not, comment it out, like so:
<!-- <div class="clear"></div> -->
This indeed moves up your sidebar to the position you want. However, I suspect you will want the last div (of class col-md-8) to be positioned higher. If so, it sounds as if you will need to create two columns inside the row (the div of class row).