Arrange columns as size in bootstrap - css

I am dynamically printing bootstrap columns divs as follows using angular2
[col-md-6][col-md-12][col-md-6][col-md-12][col-md-6][col-md-12][col-md-6][col-md-12]
but the actual grid is appearing as
[col-md-6]
[col-md-12]
[col-md-6]
[col-md-12]
[col-md-6]
[col-md-12]
[col-md-6]
[col-md-12]
I want to arrange columns like
[col-md-6][col-md-6]
[col-md-12]
[col-md-12]
[col-md-6][col-md-6]
[col-md-12]
[col-md-12]
Here is the code
<div class="row">
<span *ngFor="let serviceItem of dashboardServicesList">
<div class="col-md-6 {{serviceItem.service}}-service">
<div class="service">
<a *ngIf="serviceItem.categoryHashmap" (click)="showSegments($event,serviceItem.service)">
<span class="service-title">{{serviceItem.displayName}}</span>
<i class="fa {{serviceItem.chevron}}" aria-hidden="true"></i>
</a>
</div>
</div>
<div *ngIf="serviceItem.categoryHashmap" class="col-md-12 segments {{serviceItem.is_active}} {{serviceItem.service}}">
<ul class="segments-boxes">
<li *ngFor="let item of serviceItem.serviceSegments">
<a target="_blank" href="{{item.url}}">{{item.displayName}}</a>
</li>
</ul>
</div>
</span>
</div>
How to arrange this ? thank you.

The reason why this is happening is because of the sequence you're using.
col-md-6 + col-md-12 = col-md-18
This won't fit on one row and thats why it isn't working.
Fix your sequence and add row's to it, output as example below:
[row][col-md-6][col-md-6][row][row][col-md-12][row][row][col-md-12][row][row][col-md-6][col-md-6][row][row][col-md-12][row]
Hope this helps!

Related

Formatting text in an accordian in bootstrap 4

So I'm struggling to format an accordian in bootstrap 4 which I'm using alongside django
The basic issue with my formatting is illustrated in the picture below. The headline in the text is spilling over to outside the column of the accordian. I feel like this should be a simple fix but I can't figure it out. Code pasted below
<div class='col-xs-12 col-md-4'>
<h3> ATP tennis </h3>
<hr/>
<div id="accordion">
{% for obj in tennis %}
<div class="card">
<div class="card-header">
<h5 class="mb-0">
<button class="first1 btn btn-link collapsed newwrap" data-toggle="collapse"
data-artid="{{obj.id}}" data-target="#tnis_{{ obj.id }}" aria-expanded="false"
aria-controls="tnis_{{ obj.id }}">
{{obj.headline}}
</button>
</h5>
</div>
<div id="tnis_{{ obj.id }}" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
<div class="card-body body_pad"><a href='{{obj.url}}' target="_blank" class='body_col'>
{{obj.summary}} </a><br>
<div class="rght3">
<i id="{{obj.id}}" class="likes fa fa-thumbs-up" data-artid="{{obj.id}}" style="font-size:25px;color:#6666ff;"></i>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
I feel like this should in theory be a pretty simple fix. Any help would be much appreciated. The {{obj.headline}} is the culprit that is spilling over (which sits within a button tag)

Trying to change CSS of elements of a Loop in Laravel

Question
Hi, I am trying to print the first two categories images with col-xl-6, and the remaining categories images with col-xl-4. The size of the first two images is different from the last three. Please let me know how it will work. If you can share code it'll be awesome! Thanks.
Blade-File
#foreach ($categories as $cat)
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 column">
<a href='/products/{{$cat->id}}'>
{{-- style="height: 460px; width:345px; --}}
<div class="img">
<img class="cat-img mx-2" id="cat-img" src="/uploads/categories/{{$cat->image_url}}" />
</div>
</a>
<div class="title text-center">
<h2>{{$cat->title}}</h2>
<a href='products/{{$cat->id}}'>Shop Now</a>
</div>
</div>
#endforeach
There is a $loop variable available that you can check if the index of current item with.
https://laravel.com/docs/8.x/blade#the-loop-variable
#if ($loop->index === 0 || $loop->index === 1)
// do stuff
#endif

Inline Search Bar Materialize CSS

How can I have both my search box and badge horizontally in single row in the navbar ? I'm using materialize CSS
<nav class="orange" role="navigation">
<div class="nav-wrapper container">
<a id="logo-container" href="/" class="brand-logo white-text">C.U.P.S</a>
<ul class="right">
<a class="waves-effect waves-light btn-small indigo" href="cart"> <i class="material-icons left">add_shopping_cart</i> Cart <span class="badge white-text" data-badge-caption={{ count((array) session('cart')) }}></span></a>
<form class="col s12">
<div class="inline">
<div class="input-field col s6">
<input id="search" type="text" class="validate" placeholder="Search...">
</div>
<div class="input-field col s6">
<button class="waves-effect waves-light btn-small indigo" type="submit" name="action">Search</button>
</div>
</div>
</form>
</ul>
</div>
</nav>
If you upload your problem into a CodePen, it is easier for people to try out your code, adapt it and help you. It doesn't take long, I added your stuff in around 5 minutes, with taking care of scripts and links, but it will be a great help for people who want to help you solve your problem.
So, some general stuff about the materialize grid:
To make text fields inline, you need to add the inline class to the input-field-div (can be found in the examples of Materialize Text Inputs). Adding an enclosing div does not work
Columns only work with an enclosing row, which the <form> does not have. This is also part of your problem, more down below
The grid is based on 12 columns. So the form with col s12 will take up the complete row
If you want to split the form 50:50, you need to put the form in their own container. If not, the col will assume, that it is referencing the container around the whole navbar (more about Grids in Materialize
An unordered list (ul-tags) should always have list-items (li-tags) for each individual part of the unordered list
So, regarding your problem: Add list items to your unordered list, one for the badge, one for the search form. Then, you also need to add a div with the row-class to your form, as well as a container for the elements to get back into a local context. Add the inline-class to the right element, and you are good to go. Here's a CodePen with a working example. Hope it helps and you understand why it didn't work before!
edit: update codepen link
Try by this way
<nav class="orange" role="navigation">
<div class="nav-wrapper container">
<a id="logo-container" href="/" class="brand-logo white-text">C.U.P.S</a>
<ul class="right">
<a class="waves-effect waves-light btn-small indigo" href="cart"> <i class="material-icons left">add_shopping_cart</i> Cart <span class="badge white-text" data-badge-caption={{ count((array) session('cart')) }}></span></a>
<form class="col s12">
<div class="row">
<div class="input-field col s6">
<input id="search" type="text" class="validate" placeholder="Search...">
</div>
<div class="input-field col s6">
<button class="waves-effect waves-light btn-small indigo" type="submit" name="action">Search</button>
</div>
</div>
</form>
</ul>
</div>
</nav>
Add row class instead of inline

Get elements in ion-footer-bar to line up directly below each other

How do you get elements in ion-footer-bar to line up directly below each other rather than stack up next to each other?
For example, this:
Is produced by the code below:
<ion-footer-bar>
<div>
sdsd
</div>
<div class="button-bar">
<a class="button button-positive">First</a>
<a class="button button-positive">Second</a>
</div>
</ion-footer-bar>
In the example above, I'd like each element to be placed directly under each other, as opposed to next to each other.
The solution is to create another footer as you can see in this tuto : https://www.tutorialspoint.com/ionic/ionic_js_footer.htm
In your exemple, the solution would be :
<ion-footer-bar class="bar-subfooter>
<div>
sdsd
</div>
</ion-footer-bar>
<ion-footer-bar class="bar-subfooter>
<div class="button-bar">
<a class="button button-positive">First</a>
</div>
</ion-footer-bar>
<ion-footer-bar>
<div class="button-bar">
<a class="button button-positive">Second</a>
</div>
</ion-footer-bar>

Blade bootstrap foreach get nice-looking grid-system

I'm having this piece of code in my Laravel's Blade view:
#foreach ($questions as $question)
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
#if(isset($question->task))
<h4> <span class='glyphicon glyphicon-file'></span> {{$question->Task->name}}</h4>
#endif
<blockquote >
<a class="nostyle" href="{{URL::action('showQuestion',$question->id)}}" ><p
#if($question->status==1)
class="text-success"
#endif
>{{$question->text}}</p></a>
<footer>Gevraagd door <strong>{{$question->Author->getFullName('mij') }}</strong> op <strong>{{DateConverter::dateToString($question->created_at)}}</strong></footer>
#if($question->status==1)
<span class="label label-success">Beantwoord</span>
#endif
</blockquote>
</div>
#endforeach
Showing all the questions. I want them to be displayed in nice rows of 3. However, some texts ($question->text) are longer than others, therefore they won't always perfectly start a new row, but append to the shortest previous grid, as you can see in the screenshot.
What I want would be more like a table, three columns, and then a new row on the same height with three new items.
So I'm looking for a way to
either return all the columns the same height
or automatically adding and closing a row div after each three columns.
What would be the best way to do this?
You may try something like this:
#foreach(array_chunk($questions->all(), 3) as $threeQuestions)
<div class="row">
#foreach($threeQuestions as $question)
// Do everything here
#if(isset($question->task))
<h4> <span class='glyphicon glyphicon-file'></span> {{$question->Task->name}}</h4>
#endif
// ...
#endforeach
</div>
#endforeach
Here, $threeQuestions contains three items per iteration, so .row will keep each three items within a div like this:
<div class='row'>
item-1
item-2
item-3
</div>
<div class='row'>
item-4
item-5
item-6
</div>

Resources