collapse panel in tablet view - html

I have a toolbar. When I click on it I have many panels appear on the screen as drop-down.
In the tablet view I want all the panels to collapse and When I click on the panel-heading I want the panel-body to open.
I am poor in css can anyone help me.
Here is the code.
<div class="panel-collapse col-md-2 col-sm-4 col-xs-4 collapse in" style="height: auto;">
<div class="panel-body">
<div class="panel panel-info">
<div class="panel-heading">
<a >First heading</a>
</div>
<div class="panel-body">
<ul class="">
<li><a >item1</a></li>
<li><a >item2</a></li>
</ul>
</div>
</div>
</div>
<div class="panel-collapse col-md-2 col-sm-4 col-xs-4 collapse in" style="height: auto;">
<div class="panel-body">
<div class="panel panel-info">
<div class="panel-heading">
<a>second heading</a>
</div>
<div class="panel-body">
<ul class="">
<li><a >item4</a></li>
<li><a >item3</a></li>
</ul>
</div>
</div>
</div>

As you are using bootstrap accordion. You need to remove class in from your panel-collapse div.
Instead of
<div class="panel-collapse col-md-2 col-sm-4 col-xs-4 collapse in" style="height: auto;">
Write
<div class="panel-collapse col-md-2 col-sm-4 col-xs-4 collapse" style="height: auto;">
in is the class, which makes the content panel visible. So if you want all the panels collapse, remove it form every panel container. If you want only one panel to be visible while others should be collapsed, then put it in that panel container only.
Let me know if this helps. :-)

Bootstrap has specialized classes and data-* attributes for these types of tasks.
1) First, in order to make your panel act as an accordion, you need to give:
<a data-toggle="collapse" data-target="#panel1">Heading</a>
where panel1 is the id of your panel-body.
2) Next, since you want your panel-body to be collapsed at first, give the collapse class next to your panel-body:
<div id="panel1" class="panel-body collapse">
Have a look at the demo here to make things clear.

<div class="panel-body columnBody" id="accordion2">
<div class="panel panel-info">
<div class="panel-heading">
<a data-toggle="collapse" data-parent="#accordion" data-target=".Empty">{{item.key}}</a>
<button class="btn navbar-btn displayMobile" data-parent="#accordion2" data-target=".view{{$index}}"><span class="caret"></span></button>
</div>
<div class="panel-body itemList view{{$index}}">
<ul style="margin-bottom: 0px;">
<li ng-repeat="ke in item.values">{{ke}}</li>
</ul>
</div>
</div>
</div>
css code:
#media screen and (min-width: 850px){
.displayMobile{
display: none;
}
.itemList{
display: none;
}
}

Related

How to prevent that vertical pills overlap with tab contents?

I'm using bootstrap 4 in a web application for organizing topography measurements.
On one page, a plot of such a topography is shown in an <div class='tab-content'> element.
There are two navigation pills, "Plot" and "Properties", which allow to select the tab contents.
Here is a simplified version of the original markup:
<div class="container">
<div class="row">
<!-- The leftmost column contain a vertical navigation bar -->
<div class="col-md-1 mb-2 border-right">
<div class="nav nav-pills flex-column" role="tablist" aria-orientation="vertical">
<a class="nav-link active" data-toggle="tab" href="#plot" role="tab">Plot</a>
<a class="nav-link" data-toggle="tab" href="#properties" role="tab">Properties</a>
</div>
</div>
<!-- Columns in the middle change depending on selected pill-->
<div class="col-8">
<div class="tab-content mt-2">
<div class="tab-pane fade active show" id="plot" role="tabpanel" aria-labelledby="plot-tab">
Some plot.
</div>
<div class="tab-pane fade" id="properties" role="tabpanel" aria-labelledby="properties-tab">
Some properties.
</div>
</div>
</div>
<!-- Rightmost 3 columns are a button area -->
<div class="col-3">
<div class="row p-3 pull-right">
<button class="btn btn-primary">
A button
</button>
</div>
</div>
</div>
And here is a fiddle, where you can see it in action.
The pills work, but my problem is that sometimes in my application (depending on the zoom level of my page) and also in the fiddle, the blue background of the selected pill overlaps with the border and with the tab contents:
Could someone give me a hint how to prevent the pills from overlapping, e.g. by CSS?
I would like to have the pills completely on the left of the vertical border.
leftmost column is overflowing the content because of col-1 , you can use bootstrap media query (xs, sm, md, lg, xl) for dividing columns.
<div class="container">
<div class="row">
<!-- The leftmost column contain a vertical navigation bar -->
<div class="col-md-3 col-4 mb-2 border-right">
<div class="nav nav-pills flex-column" role="tablist" aria-orientation="vertical">
<a class="nav-link active" data-toggle="tab" href="#plot" role="tab">Plot</a>
<a class="nav-link" data-toggle="tab" href="#properties" role="tab">Properties</a>
</div>
</div>
<!-- Columns in the middle change depending on selected pill-->
<div class="col-md-6 col-8">
<div class="tab-content mt-2">
<div class="tab-pane fade active show" id="plot" role="tabpanel" aria-labelledby="plot-tab">
Some plot.
</div>
<div class="tab-pane fade" id="properties" role="tabpanel" aria-labelledby="properties-tab">
Some properties.
</div>
</div>
</div>
<!-- Rightmost 3 columns are a button area -->
<div class="col-md-3">
<div class="row p-3 pull-right">
<button class="btn btn-primary">
A button
</button>
</div>
</div>
</div>
</div>

Want to freely drag and drop using ng2-drag-drop angular 2

I am facing some issues while using ng2-drag-drop .
I want to freely drag and drop from one div to another div and then want to drag the dropped div freely in the droppable area.
Issue 1) Whenever i am dropping my draggable div in the corners of droppable area my divs shrink.
Issue 2) I want to drag the dropped items and for that i have applied draggable attribute to the dropped items. But it just make duplicate copies of the dropped items. Is there any way to control it so that I can drag the dropped item freely without making any duplicate copies?
<div class="container">
<div class="row">
<div class="col-xs-12">
<nav class="breadcrumb">
<a class="breadcrumb-item" href="#">Home ></a>
<a class="breadcrumb-item" href="#">Library ></a>
<a class="breadcrumb-item" href="#">Data ></a>
<span class="breadcrumb-item active">Bootstrap</span>
</nav>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-9">
<div class="row drag-drop-area">
<div class="col-xs-12 col-sm-4 col-lg-3 bg-white left-sidebar">
<button class="btn room-obj-btn">Room Objects <span
class="glyphicon glyphicon-arrow-right pull-right"></span></button>
<div class="category">Type</div>
<div class="drag-drop">(Drag and drop to add item)</div>
<div class="row">
<div class="col-xs-6 col-sm-12 col-md-6 surgery-objects-block"
draggable [dragData]="'Item 1'">
<div class="surgery-elements">item 1</div>
</div>
</div>
</div>
<div class="droppable-area col-xs-12 col-sm-8 col-lg-9 drop-area"
droppable (onDrop)="onItemDrop($event,evt)" style="min-height: 883px">
<div class="abc" *ngFor="let item of droppedItems"
style="position: absolute" [style.top]="item.nativeEvent.layerY + 'px'"
[style.left]="item.nativeEvent.layerX +'px'"> <div class="surgery-
elements" draggable >Item 1</div></div>
</div>
</div>
</div>
</div>
</div>
Please find plunker demo below that i have created.
http://plnkr.co/edit/UtgrchNDpiq6CAssilyR?p=preview
Solution for Issue 2
complete-demo-component.html
Add dragData and dragScope properties to your draggable Div.
Add indexing *ngFor="let item of droppedItems; let i = index;"
Change in draggable div <div class="surgery-elements" draggable [dragScope]="'alreadyDropped'" [dragData]="i" >Item 1</div>
<div class="col-xs-12 col-sm-9">
<div class="row drag-drop-area">
<div class="col-xs-12 col-sm-4 col-lg-3 bg-white left-sidebar">
<button class="btn room-obj-btn">Room Objects <span class="glyphicon glyphicon-arrow-right pull-right"></span></button>
<div class="category">Type</div>
<div class="drag-drop">(Drag and drop to add item)</div>
<div class="row">
<div class="col-xs-6 col-sm-12 col-md-6 surgery-objects-block" draggable [dragScope]="'leftItem'" [dragData]="{'data':'Item 1', isFirstTimeDrop:'true'}">
<div class="surgery-elements">item 1</div>
</div>
</div>
</div>
<div class="droppable-area col-xs-12 col-sm-8 col-lg-9 drop-area" droppable [dropScope]="['leftItem', 'alreadyDropped']" (onDrop)="onItemDrop($event,evt)" style="min-height: 883px">
<div class="abc" *ngFor="let item of droppedItems; let i = index;" style="position: absolute" [style.top]="item.nativeEvent.layerY + 'px'" [style.left]="item.nativeEvent.layerX +'px'"> <div class="surgery-elements" draggable [dragScope]="'alreadyDropped'" [dragData]="i" >Item 1</div></div>
</div>
</div>
</div>
complete-demo-component.ts
onItemDrop(e: any,evt) {
// Get the dropped data here
alert(JSON.stringify(e));
if(e.dragData.isFirstTimeDrop != undefined) {
this.droppedItems.push(e);
} else {
this.droppedItems[e.dragData] = e;
}
}
Plnkr Link http://plnkr.co/edit/pMRjGfHncUDf8PtVQIoT?p=preview

How do i make div overflow over the other content at the bottom?

i have the following html code for the bootstrap collapse
<div class="panel-group" id="accordion" style="margin-left:890px;width:444px;padding:0px;border:0px solid black;">
<div class="panel panel-default">
<div class="panel-heading" style="padding:0px;">
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo" style="border:0px;width:442px;margin:0px;" data-parent="#accordion">
<span style="float:left;">Month Calendar</span>
<span class="glyphicon glyphicon-menu-down" style="float:right"></span>
</button>
</div>
<div id="demo" class="panel-collapse collapse in" style="border:0px solid black;padding:0px;">
<div class="panel-body" style="padding:0px;">
#Html.DevExpress().DateNavigator(Html.GetSchedulerSettings()).Bind(Model.Appointments, Model.Resources).GetHtml()
</div>
</div>
</div>
</div>
this has a dev express control. when the page loads the navigator (this is a calendar) displays expanded and the context underneath it moves. So to prevent this i need to make the calendar overflow over the content. How do i make this calendar control overflow over the other?
here is an image to show whats happening
You should make the panel-default position: relative so that it's descendants are bound to it and then make the panel-collapse position: absolute to prevent it from affecting the rest of the flow.
<div class="panel-group" id="accordion" style="margin-left:890px;width:444px;padding:0px;border:0px solid black;position:relative">
<div class="panel panel-default">
<div class="panel-heading" style="padding:0px;">
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo" style="border:0px;width:442px;margin:0px;" data-parent="#accordion">
<span style="float:left;">Month Calendar</span>
<span class="glyphicon glyphicon-menu-down" style="float:right"></span>
</button>
</div>
<div id="demo" class="panel-collapse collapse in" style="border:0px solid black;padding:0px;position:absolute;top:100%;">
<div class="panel-body" style="padding:0px;">
#Html.DevExpress().DateNavigator(Html.GetSchedulerSettings()).Bind(Model.Appointments, Model.Resources).GetHtml()
</div>
</div>
</div>
</div>
Note: You are using alot of inline styles, it is best to keep as much of styling as possible in css.

Legacy Bootstrap Span Issue

I am working with a legacy bootstrap tool for my company. An issue I am having is using panels from bootstrap 3 in the legacy version.
While this is working to an extent, there are some span issues that are coming up.
I have a container with a panel on the page which is inside of a span12 (full length of the page). Within the panel, I am trying to add another panel that is full width of it. Normally I would say, span12 and it would adjust it to what is necessary but in this case, its causing it to hang over.
Here is a sample of the HTML being used:
<div id="main" class="container">
<div class="panel panel-primary custom-panel">
<div class="panel-heading ph"> <span class="panel-title"><i class="icon-bullhorn"></i> Request Communication</span><button name="addComment" commenttype="request" type="button" class="btn btn-mini pull-right"><i class="icon-plus"></i> Add Comment</button></div>
<div class="panel-body well">
<div id="requestComments" class="tab-pane active">
<span name="messages">
<div name="parent_32" class="row parentMessage">
<div class="span12">
<div class="panel panel-default">
<div class="panel-heading">
<small><a target="_BLANK" href="#">Name</a> <span class="text-muted">commented <a title="Timestamp: 2015-08-24 11:20 UTC" data-toggle="tooltip" class="deco-none">2 days ago</a></span></small>
<div class="btn-group pull-right">
<button aria-expanded="false" aria-haspopup="true" data-toggle="dropdown" class="btn btn-default btn-mini dropdown-toggle" type="button"><i class="icon-cog"></i></button>
<ul class="dropdown-menu">
<li><a messageid="32" name="deleteParent"><i class="icon-trash"></i> Delete Message</a></li>
</ul>
</div>
</div>
<div class="panel-body"><small>dgdfgdfg</small></div>
</div>
</div>
</div>
</span>
</div>
</div>
</div>
</div>
Fiddle: http://jsfiddle.net/j2j6gnb1/
How can I go about making the inner panel, the full width of its parent (with the same padding it has on the left)?
Remove the margins being set on elements .parentMessage and .span and set width: 100% on the .span12 element.
.parentMessage {
margin: 0;
}
.span12 {
width: 100%;
margin: 0;
}
Fiddle

Responsive Columns Collapsing Too Soon

I am using Bootstrap 3 and I want 3 columns to remain responsive throughout different sized (lg -> xs). I am trying to use the grid system with col-xx-4 for each size, but as soon as I get to <992px the column start collapsing on each other.
example can be see here
I want the red, green, and blue columns within the gray box to be always equal 3 columns. Maybe in xs they can collapse, but at least until 768px viewport they should be 3 columns next to each other.
I used col-xs-4 that should keep things horizontal at all times.
excerpt of some of my code:
<div class="dash-bg">
<div class="" style="background: #d5d5d5; height: 500px;">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4" style="background: red; height: 30px;">
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4" style="background: blue; height: 30px;">
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4" style="background: green; height: 30px;">
</div>
</div>
</div>
Well, you should add class "Row" to Header..
Code snippet here :
<div class="header row">
<div class="logo pull-left" style="background:black;">
</div>
<div class="pull-right" style="margin-top: 6.2%;">
<ul class="nav nav-pills">
<li>COMPANY<span class="arrow-down glyphicon glyphicon-play"></span></li>
<li>FAQ</li>
</ul>
</div>
<!--
<div class="navbar-header dropdown">
<button class="navbar-toggle" data-target=".navbar-collapse" data-toggle="dropdown" type="button">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a id="dLabel" role="button" data-toggle="dropdown" data-target="#" href="/page.html"></a>
</div>
-->
</div>
Defining DOM element row will make sure that the maximum height of any child DOM element will be the maximum height of the parent DOM.
Sounds like you need to use a media query OR make your dash-bg {min-width:993px;}
I have something similar and i use
<div class="row">
<div class="col-md-4">Something</div>
<div class="col-md-4">Something</div>
<div class="col-md-4">Something</div>
</div>
You can check an example here