Here is my codepen : https://codepen.io/Johngtrs/pen/oNWLYEw
When I click on the rotate button the div img container rotate, but the image overlap on the other row.
How it's possible to adjust the height of the img if needed ?
CSS:
.row-documents {
display: flex;
flex-direction: row;
align-items: center;
}
.row-documents img {
width: 615px;
}
.img-document {
transition: all 0.3s ease;
}
.rotate-button {
margin: 0 10px;
width: 50px;
display: flex;
justify-content: center;
}
HTML:
<div>
<div class="row-documents">
<div class="img-document">
<img src="https://picsum.photos/1300/740" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
<div class="img-document">
<img src="https://picsum.photos/1300/740" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
</div>
<hr />
<div class="row-documents">
<div class="img-document">
<img src="https://picsum.photos/1300/740" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
<div class="img-document">
<img src="https://picsum.photos/1300/740" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
</div>
</div>
For the moment you cannot do this with Css only
you can check if your image is on the portrait format and change height of the parent when it is so
$('.btn-rotate').on('click', function () {
let $img = $(this).parent().prev();
let width = $img.width();
let height = $img.height();
let angle = ($img.data('angle') + 90) || 90;
let scale = height < width ? height / width : width / height;
if (angle % 180) {
$img.css({'transform': 'rotate(' + angle + 'deg) scale('+ scale +')'});
$img.data('angle', angle);
}
else {
$img.css({'transform': 'rotate(' + angle + 'deg) scale(1)'});
$img.data('angle', angle);
}
})
.row-documents {
display: flex;
flex-direction: row;
align-items: center;
}
.row-documents img {
max-width: 215px;
max-height: 200px;
}
.img-document {
transition: all 0.3s ease;
transform-origin: center center;
display: flex;
justify-content: center;
}
.rotate-button {
margin: 0 10px;
width: 50px;
display: flex;
justify-content: center;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div>
<div class="row-documents">
<div class="img-document">
<img src="https://picsum.photos/1300/740" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
<div class="img-document">
<img src="https://picsum.photos/740/1300" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
</div>
<hr />
<div class="row-documents">
<div class="img-document">
<img src="https://picsum.photos/1300/740" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
<div class="img-document">
<img src="https://picsum.photos/1300/740" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
</div>
</div>
Related
html
<div class="container">
<div id="movies" class="well">
<div class="col-md-3">
<div class="well text-center">
<img src="#">
<h5>title</h5>
<a class="btn btn-primary" href="#">Detail</a>
</div>
</div>
<div class="col-md-3">
<div class="well text-center">
<img src="#">
<h5>title</h5>
<a class="btn btn-primary" href="#">Detail</a>
</div>
</div>
</div>
</div>
css
#movies img, #movie img{
width: 100%;
}
#media(min-width:960px){
#movies .col-md-3 .well{
height: 390px;
}
#movies .col-md-3 img{
height: 240px;
}
}
img As you can see in the image, the Detail buttons are not in the same horizontal line. I would like to push the first one down.
You can use flexbox to achieve this. Try this (View it in "full page" mode).
#movies img, #movie img {
width: 100%;
}
#media(min-width:960px) {
#movies .col-md-3 .well {
height: 350px;
display: flex;
flex-direction: column;
align-items: center;
}
#movies .col-md-3 img {
height: 240px;
}
#movies .btn {
margin-top: auto;
}
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
<div class="container">
<div id="movies" class="row well">
<div class="col-md-3">
<div class="well text-center">
<img src="https://via.placeholder.com/260">
<h5>Qui minim nulla veniam.</h5>
<a class="btn btn-primary" href="#">Detail</a>
</div>
</div>
<div class="col-md-3">
<div class="well text-center">
<img src="https://via.placeholder.com/260">
<h5>Ut reprehenderit cillum occaecat sint voluptate</h5>
<a class="btn btn-primary" href="#">Detail</a>
</div>
</div>
</div>
</div>
From *ngFor loop I can populate images but I want to add a button below the image or on the image. I'm not familiar with CSS below is my code.
Html code
<div class="container">
<div *ngFor="let img of imageData">
<p [hidden]="true">{{img.Id}}</p>
<img class="original" [alt]="img.Name"
src="https://localhost:44349/{{img.ImagePath}}"
width="350" height="350"/>
<button type="submit" (click)="deleteImage()" class="btn btn-danger"><i
class="far fa-trash-alt"></i>
Remove
</button>
</div>
</div>
CSS
.container {
position: relative;
text-align: center;
}
.original {
width: 250px;
height: 250px;
float: left;
margin: 1.66%;
transition-duration: 0.3s;
border-radius: 15px;
}
Hope this is what you are looking for.
.container {
/* position: relative;*/
text-align: center;
display: flex;
flex-direction: column;
}
.original {
width: 250px;
height: 250px;
float: left;
margin: 1.66% auto;
transition-duration: 0.3s;
border-radius: 15px;
}
.content {
display: flex;
flex-direction: column;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<div class="container">
<div class="content">
<p>Image Id</p>
<img class="original" src="https://www.w3schools.com/bootstrap/cinqueterre.jpg" width="350" height="350" />
<button type="submit" class="btn btn-danger"><i class="far fa-trash-alt"></i>
Remove
</button>
</div>
<div class="content">
<p>Image Id</p>
<img class="original" src="https://www.w3schools.com/bootstrap/cinqueterre.jpg" width="350" height="350" />
<button type="submit" class="btn btn-danger"><i class="far fa-trash-alt"></i>
Remove
</button>
</div>
</div>
For angular with dynamic image your template will be like.
<div class="container">
<div class="content" *ngFor="let img of imageData">
<p [hidden]="true">{{img.Id}}</p>
<img class="original" src="https://localhost:44349/{{img.ImagePath}}" width="350" height="350" />
<button type="submit" class="btn btn-danger"><i class="far fa-trash-alt"></i>
Remove
</button>
</div>
</div>
I have some buttons on a row, two aligned on the left and one aligned on the right as follows:
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 60px;
/* Vertically center the text there */
line-height: 60px;
background-color: #f5f5f5;
}
.fa-arrows-alt {
color: rgb(231, 81, 37);
cursor: pointer;
}
<script src="https://use.fontawesome.com/23ac9aaa92.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="row">
<div class="col-12 col-md-12">
A div here
</div>
<div class="col-12 col-md-12">
<button type="button" class="btn btn-outline-dark btn-sm">Edit</button>
<button type="button" class="btn btn-outline-dark btn-sm">Delete</button>
<i class="fa fa-arrows-alt fa-2x float-right"></i>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<span class="text-muted">Place sticky footer content here.</span>
</div>
</footer>
I would like the buttons to force them to be always on the bottom of the div, above the footer. I tried using bottom: 0 and position absolute, fixed but I received an unexpected result. Any suggestions are welcome.
use bootstrap 4 position-absolute predefined class and add bottom:0
.position-absolute {
bottom: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid position-absolute">
<div class="row">
<div class="col-12 col-md-12 btn-row">
<button type="button" class="btn btn-outline-dark btn-sm">Edit</button>
<button type="button" class="btn btn-outline-dark btn-sm">Delete</button>
<button type="button" class="btn btn-outline-dark btn-sm float-right">Full Screen</button>
</div>
</div>
</div>
Use the flexbox classes that are built in to Bootstrap. You just need CSS to make sure the body is display:flex and full height...
https://www.codeply.com/go/lEaF85K1KU
CSS
body {
height:100vh;
display: flex;
flex-direction: column;
}
.flex-fill {
flex: 1 1 auto;
}
HTML
<main class="container-fluid d-flex flex-column flex-fill">
<div class="row flex-column flex-fill">
<div class="col-12 flex-fill">
A div here
</div>
<div class="col-12">
<button type="button" class="btn btn-outline-dark btn-sm">Edit</button>
<button type="button" class="btn btn-outline-dark btn-sm">Delete</button>
<i class="fa fa-arrows-alt fa-2x float-right"></i>
</div>
</div>
</main>
<footer class="container-fluid bg-light py-3">
Sticky Footer
</footer>
Note: The flex-fill utility class will be included in the next Bootstrap 4.1 release. So after that release the extra CSS for flex-fill won't be needed.
To get something to stick to the bottom of the screen, do
<footer class="fixed-bottom">
To get buttons to go left and right give each button a class of “pull-left” or “pull-right”
This is my css and HTML template file.
#wrapper {
display: inline!important;
height: 275px;
max-width: 540px;
}
.box {
margin: 5px;
display: inline-block;
width: 170px;
height: 275px!important;
background-color: #F5FBEF;
text-align: center;
float: left;
}
.ng-repeat {
display: inline-block;
}
HTML File
<br>
<div>
<div ng-if="SearchText.length<3" ng-repeat="product in pc.ProductService.Products | filter:FilterExpr:true |orderBy:['SubCategoryName','BrandName'] | groupBy:['BrandName']" >
<div ng-show="product.group_by_CHANGED"><h2>{{product.BrandName}} </h2></div>
<div id=wrapper>
<div class='box'>
<ng-include src="'commonTemplate.html'"></ng-include>
</div>
</div>
</div>
<!-- template (common piece of code) -->
<script type="text/ng-template" id="commonTemplate.html">
<div class="BrandName"> <b>{{product.BrandName}}</b> </div>
<div class="ProductName"> {{product.ProductName}} </div>
<br>
<div> <img src="http://localhost/{{ product.ProductImagePath }}" alt="" border=3 height=75 width=75></img> </div>
<div class="ProductVariants">
<select class="form-control btn btn-default btn-xs text-center" ng-init="SelectedVariant = product.Variants[0]" ng-model="SelectedVariant" ng-options="variant.VariantName for variant in product.Variants" ng-change="ChangeVariant(product.ProductID, SelectedVariant.VariantID)"></select>
</div>
<div class="Price">
<strike> {{SelectedVariant.MRP}} </strike> {{SelectedVariant.SellPrice}}
</div>
<div class="AddToCart" ng-if="SelectedVariant.InCart==0">
<a class="btn btn-success btn-sm" ng-click="pc.AddToCart(product.ProductID, SelectedVariant.VariantID)">Add to Cart
<span class="glyphicon glyphicon-plus"></span>
</a>
</div>
<div class="AddToCart" ng-if="SelectedVariant.InCart>0">
<a class="btn btn-default btn-xs" ng-click="pc.PlusItem(product.ProductID, SelectedVariant.VariantID)">
<span class="glyphicon glyphicon-plus"></span>
</a>
<button type="button" class="btn btn-sm btn-info disabled">{{SelectedVariant.InCart}} in cart</button>
<a class="btn btn-default btn-xs" ng-click="pc.MinusItem(product.ProductID, SelectedVariant.VariantID)">
<span class="glyphicon glyphicon-minus"></span>
</a>
</div>
</script>
</div>
This is how my page looks like-
What i want when new brand comes say annapurna or panchratan, display that in new line. and then in next line display all the products of that brand.
(similar to aashirvad first brand.)
How to do that?
You have to wrap whole template with outer div that is full width:
<script type="text/ng-template" id="commonTemplate.html">
<div class="brand-wrapper">
<div class="BrandName"> <b>{{product.BrandName}}</b> </div>
...
</div>
</script>
// May be omitted as div already block element.
.brand-wrapper {
clear: both; // if floated
width: 100%;
display: block;
}
Change wrapper:inline to inline-block and it should work. Also put your h2 inside the wrapper.
Also, change the float on the box to float:right;
I know this question has been asked several time before, and generally I can fix it myself, but for some reason I can not get these icons to center. They are always left aligned. If the good people of SO wouldn't mind taking a look I would be much obliged. It is probably an easy fix, I'm just overlooking something.
HTML:
<div class="footerSection">
<div class="col-lg-4 col-md-4 col-sm-4 btn-toolbar">
<span id="" class="btn btn-lg footerMainButton"></span>
</div>
<div id="footerInside" class="col-lg-4 col-md-4 col-sm-4">
<div class="divOuter col-lg-12">
<div class="col-lg-2 col-md-2 col-sm-2 divCenter">
<button type="button" class="footerSave">
<img class="footerSvg" src="../../img/icon_disk_save.svg" alt="save" /><br /><span>Save</span>
</button>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 divCenter">
<button type="button" class="footerPreview">
<img class="footerSvg" src="../../img/icon_play.svg" alt="preview" /><span><br />Preview</span>
</button>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 divCenter">
<button type="button" class="footerDelete">
<img class="footerSvg" src="../../img/icon_trash.svg" alt="delete" /><br /><span>Delete</span>
</button>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 divCenter">
<button type="button" class="footerView">
<img class="footerSvg" src="../../img/icon_long_right_arrow.svg" alt="view" /><span><br />View/Edit</span>
</button>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 divCenter">
<button type="button" class="footerRemove">
<img class="footerSvg" src="../../img/icon_minus.svg" alt="remove" /><span><br />Remove</span>
</button>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 divCenter">
<button type="button" class="footerNewMedia">
<img class="footerSvg" src="../../img/icon_upload_arrow.svg" alt="New Media" /><span><br />New Media</span>
</button>
</div>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<button type="button" class="mapMarkerStyle">
<img style="width: 36px;height: 36px;" src="../../img/icon_map_pin_blue.svg" alt="Map Pin" /><span></span>
</button>
</div>
</div>
CSS:
.footerSection {
width: 100%;
height: 100px;
background-color: #424242;
display: block;
position: fixed;
z-index: 999;
padding: 20px 0 20px;
bottom: 0;
}
#footerInside {
display: block;
float: left
}
.divOuter {
margin: 0 auto;
}
.divCenter {
text-align: center;
}
Some notes on the code. The centered icons are display none normally until called. Using display: none as to not take up space.
Make these changes to your CSS:
#footerInside {
width: 500px;
margin: 0 auto;
}
#footerInside div {
display: block;
float: left;
}
FIDDLE: http://jsfiddle.net/dzort1rb/
Your code is working fine for me
Use class="text-center" in the parent div where you required