I'm using Bootstrap 3 to design my website. In a large window my button appears fine within its gray box and border. However, when I resize the window to check responsiveness, the button ends up being outside the boundaries of the container.
Here's my code:
<div class="col-md-4 col-sm-12 col-xs-12 gray-box top-space">
<h3><?php echo __("Test");?></h3>
<p><?php echo __("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec in est nec mauris dapibus porta sit amet sit amet diam. Cras sit amet imperdiet elit. Nunc vehicula consectetur augue a pretium.");?></p>
<a href="/pricing/" class="btn-primary pull-right" ><?php echo __("Test");?></a>
</div>
And here's the css for the gray-box.
.gray-box {
background-color: #F5F4F4;
border: 1px solid #D3D3D3;
border-radius: 10px;
padding: 10px;
}
Anyone know what I'm doing wrong or what needs to be done? Thanks!
You just forgot to add the btn class to your button. Buttons always require the btn class in addition to the btn-default (or -primary, etc.). The btn class styles the element to look like the button and the btn-* classes apply the appropriate color and hover styles.
Two solutions off the top of my head.
1) Throw a .clearfix in after your pull-right to reset it:
<div class="btn btn-primary pull-right">Button</div>
<div class="clearfix"></div>
2) Put the button in its own div:
<div >
Button
</div>
Also, no need to classify col-xs-12 and col-sm-12 and col-md-4 — the default is col-xs-12 until it hits something else, so you can just do col-md-4 for the same result.
Related
I'm trying to build course cards in which when hovered to any course card a popover should appear and popover is visible till when i hover on card and popover itself. And when I hover over to next card previous popover should be removed and current hovered card popover should appear.But when hover over another card previous pop over still exist.
Used package called react-tiny-popover react-tiny-popover
Below is the code snippet
<Popover
isOpen={isPopoverOpen}
positions={['right', 'left', 'top', 'bottom']}
padding={10}
align="center"
width={200}
onClickOutside={() => setIsPopoverOpen(false)}
reposition="true"
content={({ position, childRect, popoverRect }) => (
<ArrowContainer // if you'd like an arrow, you can import the ArrowContainer!
position={position}
childRect={childRect}
popoverRect={popoverRect}
arrowColor={'white'}
arrowSize={10}
arrowStyle={{ opacity: 0.7 }}
className='popover-arrow-container'
arrowClassName='popover-arrow'
>
<div
style={{ backgroundColor: 'white', color: '#170055', padding: '10px', borderRadius: '5px', width: '300px', height: '400px', lineHeight: '1.5' }}
onClick={() => setIsPopoverOpen(!isPopoverOpen)}
>
<div class="popover-text">
<h1 style={{ fontSize: '20px' }}>Lorem ipsum.</h1>
<h2 style={{ fontSize: '14px' }} class="course-instructor">Dr. Murthy</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse vehicula rhoncus metus non condimentum. Int</p>
<ol>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse vehicula rhoncus metus non condimentum. Int</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse vehicula rhoncus metus non condimentum. Int</li>
</ol>
<button className="course-button">Add to Cart</button>
</div>
</div>
</ArrowContainer>
)}
>
<div class="tile" onMouseOver={() => setIsPopoverOpen(!isPopoverOpen)} >
<Link to={props.page}>
<img src='../../assets/images/courses-01.jpg' alt="ssd" />
<div class="text">
<h1>Lorem ipsum.</h1>
<h2 class="course-instructor">Dr. Murthy</h2>
<p className="course-price">Rs. 400</p>
</div>
</Link>
</div>
</Popover>
Try to add
onMouseLeave={() => setIsPopoverOpen(false)}
for div class="tile"
I am looping thru items with ng-repeat. Here is the code:
<div class="row"
<div class="w3-card-3 col-xs-18 col-sm-6 col-md-3" ng-repeat="p in products">
<div class="thumbnail">
<img ng-src="{{p.img}}" alt="...">
<div class="caption">
<h4 class="text-danger">{{p.brand}}</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facere, soluta, eligendi doloribus sunt minus amet sit debitis repellat. Consectetur, culpa itaque odio similique suscipit</p>
<a href="car/{{ p.id }}" class="btn btn-default btn-xs pull-right" role="button"><i class="glyphicon glyphicon-edit"></i>
</a> Info
Bid
</div>
</div>
</div>
My problem is that when the repeater enters a new line the cards generated gets messed up. Here's an image of the problem:
What's wrong with my code? Why won't the cards align underneath each other. Tell me if there is anything else you want to see.
use height of image and description wrapper it should solve the problem
Try to add style="float: left" in the div below:
<div class="thumbnail" style="float: left">
I started angularjs http request and I got data successfully as following but when I tried to make first item expanded according bootstrap class "collapse in" instead of "collapse" I didn't find solution.
Angularjs
var app = angular.module('myApp', []);
app.controller('myCtrl2', function ($scope, $http) {
$http.get('../C_Angular.asmx/ShowArticle')
.then(function (response) {
$scope.Articles = response.data;
});
});
HTML
<div class="panel-group" data-ng-repeat="Art in Articles" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" data-ng-href="{{Atr.Art_ID}}">
{{Art.Art_Title}}
</a>
</h4>
</div>
<div data-ng-id="{{Atr.Art_ID}}" class="panel-collapse collapse"> <%-- my prolblem here is
how to put a class "panel-collapse collapse in" to the first item in the list
instead of "panel-collapse collapse" --%>
<img data-ng-src="{{Art.Art_Pic}}" style="margin: 20px; border: 4px solid #FFFFFF;
width: 140px; height: 100px; float: left;" />
<div class="panel-body" style="padding: 5px; margin: 5px; text-align: right; background-image: url('../App_Pic/bg03.jpg');">
{{Art.Art_Body}}
</div>
<button type="button" class="btn btn-primary btn-sm " style="margin-bottom: 10px">Read More ...</button>
</div>
</div>
</div>
Would you help me please to find out how to add "in" class in the first item of angularjs list?
The answer you accepted is bad practice, and you might start getting this error in you app: https://docs.angularjs.org/error/$rootScope/infdig don't bind functions to the view when you don't have to.
You can do it simply with ngClass directive (Using the $first indicator that is TRUE for the first element):
<div data-ng-id="{{Atr.Art_ID}}" class="panel-collapse collapse" ng-class="{in: $first}">
The same can also be done using the $index indicator:
<div data-ng-id="{{Atr.Art_ID}}" class="panel-collapse collapse" ng-class="{in: $index == 0}">
You might also want to use one-time binding the ensure that angular stop tracking the the in class after the element is bound to the view, so it won't re-add it on each digest cycle (note the :: in the ngClass expression):
<div data-ng-id="{{Atr.Art_ID}}" class="panel-collapse collapse" ng-class="::{in: $first}">
Now - You can always use the native uib-collapse for angularjs - Here is an example:
angular.module('app', ['ngAnimate','ui.bootstrap']).controller('ctrl', function ($scope) {
$scope.Articles = [
{id: 1, title: 'Interesting article #1', body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'},
{id: 2, title: 'Interesting article #2', body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'},
{id: 3, title: 'Interesting article #3', body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'}];
});
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.3/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.3/angular-animate.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap-tpls.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<div ng-app="app" ng-controller="ctrl">
<div class="panel-group" data-ng-repeat="Art in Articles" ng-init="Art.isCollapsed = !$first">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-ng-href="{{Atr.id}}" ng-click="Art.isCollapsed = !Art.isCollapsed">{{Art.title}}</a>
</h4>
</div>
<div data-ng-id="{{Atr.id}}" class="panel-collapse collapse" uib-collapse="Art.isCollapsed">
<div class="panel-body">{{Art.body}}</div>
<button type="button" class="btn btn-primary btn-sm" >Read More ...</button>
</div>
</div>
</div>
</div>
Here i'm creating the panels similar to how you did, but in the ngRepeat loop I added ng-init="Art.isCollapsed = !$first" which initiale the first article to be visible, while the rest are not. Next, instead of using the "regular" bootstrap attributes, I just use the uibCollapse directive: uib-collapse="Art.isCollapsed" which handle everything for you.
You can use ng-class and a function to check if it is the first item as below
$scope.setClass = function(index){
//return collapse in if it is the first item
if(index == 0) return "panel-collapse collapse in";
//or return collapse in
return "panel-collapse collapse";
}
for the view change it to
<div data-ng-id="{{Atr.Art_ID}}" ng-class="setClass($index)">
Angularjs ng-repeat with div tag..i have a code with div tag as shown..i want to repeat the whole div with img src being different on the second loop..how to do this with ng-repeat directive in angularjs?
<div class="col-xs-12 col-sm-12 col-md-6" >
<a href="Events.html">
<div class="PastEvents">
<div class="EventDate"><h5>25<br /><span>Feb</span></h5></div>
<img src = "resources/front/images/UpComing-Event00.jpg">
<h6>Lorem ipsum</h6>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse non massa ut tortor volutpat eleifend eu lobortis urna.</p>
</div>
</a>
</div>
JS:
myModule.controller('ctrl', function($scope) {
$scope.imageSources = ["src1", "src2", "src3"]
})
HTML:
<div ng-repeat="src in imageSources" class="col-xs-12 col-sm-12 col-md-6" >
<a href="Events.html">
<div class="PastEvents">
<div class="EventDate"><h5>25<br /><span>Feb</span></h5></div>
<img ng-src="{{src}}">
<h6>Lorem ipsum</h6>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse non massa ut tortor volutpat eleifend eu lobortis urna.</p>
</div>
</a>
</div>
Basically, have your image sources in your controller and use the ng-src directive in your template
I'm trying understand your question.
If you wanna display different style by the index of 'ng-repeat', you can do like following.
<div class="PastEvents" ng-repeat="item in items">
<div class="EventDate"><h5>25<br /><span>Feb</span></h5></div>
<img src = "resources/front/images/UpComing-Event00.jpg" ng-if="$index == 1"><!-- first item-->
<img src = "resources/front/images/UpComing-Event00.jpg" ng-if="$index != 1"><!-- second and rest items-->
<h6>Lorem ipsum</h6>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse non massa ut tortor volutpat eleifend eu lobortis urna.</p>
</div>
If you just wanna display different resource, just using:
<img src = "resources/front/images/UpComing-Event{{$index}}.jpg">
I'm implementing a content tabbed section using Bootstrap 3 and it works fine for almost all resolutions except mobile. For some reason only on mobile devices the default active tab is the last one called "All", but the content it displays comes from the first tab ("Popular").
It works perfect on bigger resolutions like iPad or desktop. In this case the default active tab is the first one called "Popular" and the displayed content is correct.
Could you please help me to figure it out what is the problem?
<section class="solution-tabs section-tabs">
<div class="container no-padding">
<ul class="nav nav-tabs" role="tablist">
<li class="col-sm-3 active">Popular</li>
<li class="col-sm-3">Industries</li>
<li class="col-sm-3">Topics</li>
<li class="col-sm-3">All</li>
</ul>
</div>
<div class="tab-content">
<div class="tab-pane fade in active" id="tabPopular">
<div class="container">
<div class="row">
Popular tab content<br />
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Esse, est quae quo magnam deserunt facere!
</div>
</div>
</div>
<div class="tab-pane fade" id="tabIndustries">
<div class="container">
<div class="row">
Industries tab content<br />
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi, corporis obcaecati eos vero aliquam sit?
</div>
</div>
</div>
<div class="tab-pane fade" id="tabTopics">
<div class="container">
Topics tab content<br />
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus ratione iusto officiis sint quaerat totam.
</div>
</div>
<div class="tab-pane fade" id="tabAll">
<div class="container">
<div class="row">
All tab content<br />
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsam, fugit fuga doloremque minima ducimus ratione.
</div>
</div>
</div>
</div>
</section>