I have a section of a website that has 2 rows inside a container, both rows have 3 columns of class col-sm-4 and col-md-4. Both rows have 1 image in each column. All images are exactly the same size at 300px wide. The top row displays accurately, the bottom row condenses the 3 columns and leave a big area of wide space on the right side. When using the inspector, The top row columns are appearing as class col-md-4, but the buttom row columns are showing as col-sm-4. I'm not sure if this is whats causing it. I should mention also that the top row columns have paragraphs below each image. When adding the exact same paragraph content to the bottom row in just 1 column, the issue is resolved, but I don't want paragraphs here. I checked out the bootstrap CSS and my own to try and find some sore of style on <p> that could be causing this but couldn't find anything. Each row, and column have the exact same CSS. The code is below:
HTML:
<div class="wrapper">
<div class="row customer-options">
<div class="button-container">
<div class="col-sm-4 col-md-4">
<img class="img-circle img-responsive img-center" src="images/button-icon-map2.png" alt="">
<h2>Title 1</h2>
<p>These marketing boxes are a great place to put some information. These can contain summaries of what the company does, promotional information, or anything else that is relevant to the company. These will usually be below-the-fold.</p>
</div>
<div class="col-sm-4 col-md-4">
<img class="img-circle img-responsive img-center" src="images/button-icon-pref2.png" alt="">
<h2>Title 2</h2>
<p>The images are set to be circular and responsive. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
</div>
<div class="col-sm-4 col-md-4">
<img class="img-circle img-responsive img-center" src="images/button-icon-add2.png" alt="">
<h2>Title 3</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
</div>
</div>
</div><!-- /.row -->
</div><!--wrapper-->
<hr>
<div class="wrapper">
<div class="row tap">
<div class="tap-container">
<div class="col-sm-4 col-md-4">
<img class="img-circle img-responsive img-center" src="images/beer-tap.png" alt="">
<h2>About</h2>
</div>
<div class="col-sm-4 col-md-4">
<img class="img-circle img-responsive img-center" src="images/beer-tap.png" alt="">
<h2>Services</h2>
</div>
<div class="col-sm-4 col-md-4">
<img class="img-circle img-responsive img-center" src="images/beer-tap.png" alt="">
<h2>Contact</h2>
</div>
</div>
</div><!-- /.row -->
</div><!--wrapper-->
CSS:
.wrapper {
display: table;
}
.button-container {
padding-right: 15px;
padding-left: 15px;
}
.customer-options {
background-color: #848487;
padding-top: 20px;
height:100vh;
display: table-cell;
vertical-align: middle;
}
.tap {
background-color: #848487;
padding-top: 20px;
height:100vh;
display: table-cell;
vertical-align: middle;
text-align: center;
}
.tap-container {
padding-right: 15px;
padding-left: 15px;
}
.customer-options h2 {
text-align: center;
}
The display table and table-cell are taking precedence over the responsive image. Tables fit their content then the img-responsive will fill the new width. You can probably find a work around to achieve vertical alignment but I recommend dropping the table system and properly use bootstrap's grid system. Then you can use flexboxes to get vertical alignment.
http://jsfiddle.net/28qq8fm3/
<style>
.customer-options {
background-color: #848487;
padding-top: 20px;
vertical-align: middle;
}
.tap {
background-color: #848487;
padding-top: 20px;
vertical-align: middle;
text-align: center;
}
.customer-options h2 {
text-align: center;
}
</style>
<div>
<div class="row customer-options">
<div class="col-sm-4 col-md-4">
<img class="img-circle img-responsive img-center" src="https://beccasheppard.files.wordpress.com/2011/09/football.jpg" alt="">
<h2>Title 1</h2>
<p>These marketing boxes are a great place to put some information. These can contain summaries of what the company does, promotional information, or anything else that is relevant to the company. These will usually be below-the-fold.</p>
</div>
<div class="col-sm-4 col-md-4">
<img class="img-circle img-responsive img-center" src="https://beccasheppard.files.wordpress.com/2011/09/football.jpg" alt="">
<h2>Title 2</h2>
<p>The images are set to be circular and responsive. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
</div>
<div class="col-sm-4 col-md-4">
<img class="img-circle img-responsive img-center" src="https://beccasheppard.files.wordpress.com/2011/09/football.jpg" alt="">
<h2>Title 3</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
</div>
</div>
<!-- /.row -->
</div>
<!--wrapper-->
<hr>
<div>
<div class="row tap">
<div class="col-sm-4 col-md-4">
<img class="img-circle img-responsive img-center" src="http://www.cozadschools.net/wp-content/uploads/2015/02/football.png" alt="">
<h2>About</h2>
</div>
<div class="col-sm-4 col-md-4">
<img class="img-circle img-responsive img-center" src="http://www.cozadschools.net/wp-content/uploads/2015/02/football.png" alt="">
<h2>Services</h2>
</div>
<div class="col-sm-4 col-md-4">
<img class="img-circle img-responsive img-center" src="http://www.cozadschools.net/wp-content/uploads/2015/02/football.png" alt="">
<h2>Contact</h2>
</div>
</div>
<!-- /.row -->
</div>
<!--wrapper-->
Related
I'm working with mat-card in a list and I have a problem with the alignment.
Here is what I have:
Here is what I want:
The code :
<div class="margin-top-20" fxFlexFill fxLayout="row wrap" fxLayout.xs="column" fxLayout.sm="column" fxLayoutGap="15px grid">
<div fxFlex="20" fxFlex.md="33" *ngFor="let advert of adverts; let i = index" class="padding-fix">
<div fxFlexFill fxLayoutAlign="center stretch">
<mat-card class="ad">
<div fxLayoutAlign="space-between center">
<img mat-card-image src="test" alt="test">
</div>
<mat-card-title>test</mat-card-title>
<mat-card-content>
<p>
test
</p>
</mat-card-content>
<mat-card-actions align="end">
</mat-card-actions>
</mat-card>
</div>
</div>
</div>
I didn't understand I can I centre the image (resize it if necessary).
EDIT: Thank coreuter's answer, I'm close to getting what I want.
the first block is not at the same height as the others. And I've got some blank space at the end of each row (I would like 5 elements per row).
The updated code:
<div class="margin-top-20" fxLayout="row wrap" fxLayoutAlign="start center" fxLayoutGap="15px">
<mat-card fxFlex="20" (click)="addProduct()" class="mat-card-add-button">
<div>
<span style="font-size:32px;text-align:center">+<br/>Add product</span>
</div>
</mat-card>
<mat-card fxFlex="20" *ngFor="let product of products; let i = index" class="product">
<img class="image" mat-card-image src="{{product.picture.uri}}" alt="photo">
<mat-card-title>{{product.name}}</mat-card-title>
<mat-card-content>
<p>
test
</p>
</mat-card-content>
<mat-card-actions align="end">
</mat-card-actions>
</mat-card>
</div>
EDIT 2:
I think it's almost perfect. I tried with a big content inside the mat-card-content div and I don't know if it's good. Here is a screenshot of what I have:
Do you think it possible to get the buttons at the same height as the big mat-card (the last one)? Another thing, I can't see the border-left of the first element of each row.
Here the updated code :
<div class="margin-top-20" fxFlexFill fxLayout="row wrap" fxLayoutAlign="start start" fxLayoutGap="20px">
<mat-card fxLayoutAlign="center center" fxFlex="0 1 calc(20% - 20px)" (click)="addProduct()" class="product" style="height:413px">
<div>
<span fxLayoutAlign="center center" style="font-size:32px;text-align:center">+<br />Add product</span>
</div>
</mat-card>
<mat-card fxFlexFill fxFlex="0 1 calc(20% - 20px)" *ngFor="let product of products; let i = index" class="product">
<img class="image" mat-card-image src="{{product.picture.uri}}" alt="photo">
<mat-card-title>{{product.name}}</mat-card-title>
<mat-card-content>
<p *ngIf="i == 3">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam dapibus, leo id pulvinar vestibulum, ligula nisl tincidunt magna, eu volutpat leo neque quis justo. Fusce semper ante id mi porta porta. Pellentesque nec pretium purus. Curabitur lobortis tempus consectetur. Nam ullamcorper gravida erat sed suscipit. Morbi quis porttitor nunc. Suspendisse lacinia a turpis vitae laoreet. Aliquam pellentesque scelerisque urna. Cras vulputate nisi sed elit commodo cursus. Aenean interdum, erat at convallis dictum, urna enim tincidunt nisi, vitae tempor nisi nisi a tellus. Aliquam volutpat dui eget gravida eleifend. Nullam pulvinar justo eget tellus commodo, eget molestie dui convallis. Curabitur at fermentum lorem. Maecenas porttitor sem ut enim efficitur bibendum et vel metus.
</p>
<p *ngIf="i != 3">
test
</p>
</mat-card-content>
<mat-card-actions align="end">
<button mat-icon-button>
<mat-icon>mode_edit</mat-icon>
</button>
<button mat-icon-button>
<mat-icon>delete</mat-icon>
</button>
</mat-card-actions>
</mat-card>
</div>
Thank you again for your help, I really appreciate it!
EDIT 3: This version works! Thank you very much coreuter! See it on StackBlitz.
The mat-card-content is not fixed by the "fxFlex" property. The content goes outside the mat-card. (It's working on the last StackBlitz but not for me).
.mat-card {
padding: 18px !important; /* less padding than per default */
}
.mat-card-image {
width: calc(100% + 36px) !important; /* update padding */
margin: 0 -24px 16px -18px !important; /* update padding */
}
.mat-tab-label {
font-size: 16px !important;
}
.mat-card-title {
font-size:24px !important;
font-weight: 500 !important;
}
.mat-card-content {
font-size: 14px !important;
min-height: 30px; /* <--- to remove !!! */
}
.product {
margin-bottom: 25px;
/*min-width: 180px;
text-align: center;*/
}
/* desktop button */
.mat-card-add-button {
border: 1px dashed grey;
box-shadow:none !important;
cursor:pointer;
}
.product img {
height: 250px;
object-fit: contain;
}
<div *ngIf="products.length > 0" style="margin-left:10px;">
<div fxLayout="row wrap" fxLayoutAlign="start stretch" fxLayoutGap="20px">
<mat-card fxLayoutAlign="center center" fxFlex="0 1 calc(20% - 20px)" fxFlex.md="0 1 calc(25% - 20px)" fxFlex.sm="0 1 calc(33% - 20px)" fxHide.xs="true" (click)="addProduct()" class="product mat-card-add-button">
<div fxLayoutAlign="center center" style="font-size:32px;text-align:center">+<br />Add product</div>
</mat-card>
<mat-card fxLayout="column" fxFlex.md="0 1 calc(25% - 20px)" fxFlex="0 1 calc(20% - 20px)" fxFlex.sm="0 1 calc(33% - 20px)" fxFlex.xs="100" *ngFor="let product of products; let i = index" class="product">
<img mat-card-image src="{{product.picture.uri}}" alt="photo">
<mat-card-title>{{product.name}}</mat-card-title>
<mat-card-content fxFlex>
<p *ngIf="i == 3">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam dapibus, leo id pulvinar vestibulum, ligula nisl tincidunt
magna, eu volutpat leo neque quis justo. Fusce semper ante id mi porta porta. Pellentesque nec pretium purus. Curabitur
lobortis tempus consectetur. Nam ullamcorper gravida erat sed suscipit. Morbi quis porttitor nunc. Suspendisse lacinia
a turpis vitae laoreet. Aliquam pellentesque scelerisque urna. Cras vulputate nisi sed elit commodo cursus. Aenean interdum,
erat at convallis dictum, urna enim tincidunt nisi, vitae tempor nisi nisi a tellus. Aliquam volutpat dui eget gravida
eleifend. Nullam pulvinar justo eget tellus commodo, eget molestie dui convallis. Curabitur at fermentum lorem. Maecenas
porttitor sem ut enim efficitur bibendum et vel metus.
</p>
<p *ngIf="i != 3">
test
</p>
</mat-card-content>
<mat-card-actions fxFlexAlign="end" align="end">
<button mat-icon-button>
<mat-icon>mode_edit</mat-icon>
</button>
<button mat-icon-button>
<mat-icon>delete</mat-icon>
</button>
</mat-card-actions>
</mat-card>
</div>
</div>
Since I answered your previous SO question, I'll build my answer to this question upon my previous answer. Please refer to this updated Stackblitz with images of different width and height.
EDIT: Adjusted the answer/stackblitz to make a row containing 5 elements.
Explanation
In order to keep the image always the same height I've added the class "image" to the <img>-tag (you can of course apply the css to the img-tag directly with .product img{...} as well).
<img class="image" mat-card-image src="{{product.picture.url}}" alt="photo">
and applied the following CSS:
.image{
height: 150px; /* adjust as needed */
object-fit: contain;
}
With object-fit: contain your image will always properly scaled and fully visible within the available area.
Keep in mind that object-fit is currently only fully supported by the following browsers.
EDIT:
In order to get 5 Elements within each row you have to adjust the fxLayoutGap and the calculation of the width for each element using the fxFlex attribute. Please change your code as follows..
<div class="container" fxLayout="row wrap" fxLayoutAlign="center center" fxLayoutGap="20px">
<!-- Add addProduct-button outside loop -->
<mat-card fxFlex="0 1 calc(20% - 20px)" (click)="addProduct()" class="product">
...
</mat-card>
<!-- loop over the products -->
<mat-card fxFlex="0 1 calc(20% - 20px)" *ngFor="let product of products; let i = index" class="product">
...
</mat-card>
</div>
.. and change the 20px set on the fxLayoutGap and the within the calculation of fxFlex to your desired value.
With those values now set you have to apply a min-width value, otherwise all elements will just get smaller in width and the row won't wrap:
.product{
min-width: 180px; /* adjust as desired */
min-height: 250px;
margin-bottom: 20px; /* same as fxLayoutGap for even distribution */
}
EDIT 2
To make the first element the same height as the others you have to adjust to (min-)height of the .product CSS-class to be equal to the height of the highest product.
EDIT 3 (to answer edit 2 of the question)
Since you didn't mark your question answered yet, I've modified the code you provided in your edit #2 to accomplish your desired design: stackblitz
I've changed the following:
changed the fxLayoutAlign on the container to "space-evenly stretch" instead of fxLayoutAlign="start start" this distributes all items in a row on the x-axis evenly and makes them stretch as high as the highest element of the row.
removed all fxFlexFill
added fxFlex to the mat-card-content
removed the height from the .product CSS-class
Regarding the border on the left side.. I assume your container is too close to the browser windows left side. I've change the container css in my stackblitz as well.
.ad{
display:flex;
flex-direction:coloumn;
height:100%;
}
img,mat-card-content{
flex-grow: 1;
}
mat-card-actions{
display: inline-block;
align-self: flex-end;
}
You can try this.
You may have to work with fixed sizes for the mat-card and just make sure the images fit in whatever space is available.
.margin-top-20>div>div {
display: flex;
width: 100%;
}
.ad {
width: 200px;
height: 250px;
min-height: 250px;
max-width: 200px;
border: thin solid #eee;
}
.ad>div {
width: 100%;
height: 200px;
display: flex;
justify-content: center;
align-items: center;
}
.ad>div>img {
flex: 0 1;
width: 100%;
height: auto;
}
<div class="margin-top-20" fxFlexFill fxLayout="row wrap" fxLayout.xs="column" fxLayout.sm="column" fxLayoutGap="15px grid">
<div fxFlex="20" fxFlex.md="33" *ngFor="let advert of adverts; let i = index" class="padding-fix">
<div fxFlexFill fxLayoutAlign="center stretch">
<mat-card class="ad">
<div fxLayoutAlign="space-between center">
<img mat-card-image src="https://via.placeholder.com/150x50" alt="test">
</div>
<mat-card-title>test</mat-card-title>
<mat-card-content>
<p>
test
</p>
</mat-card-content>
<mat-card-actions align="end">
</mat-card-actions>
</mat-card>
<mat-card class="ad">
<div fxLayoutAlign="space-between center">
<img mat-card-image src="https://via.placeholder.com/50x150" alt="test">
</div>
<mat-card-title>test</mat-card-title>
<mat-card-content>
<p>
test
</p>
</mat-card-content>
<mat-card-actions align="end">
</mat-card-actions>
</mat-card>
<mat-card class="ad">
<div fxLayoutAlign="space-between center">
<img mat-card-image src="https://via.placeholder.com/350x150" alt="test">
</div>
<mat-card-title>test</mat-card-title>
<mat-card-content>
<p>
test
</p>
</mat-card-content>
<mat-card-actions align="end">
</mat-card-actions>
</mat-card>
</div>
</div>
</div>
I'm generating a barcode using this library and I do need to print the page including the barcode.
When I initiate the print dialog I can't find the barcode although it is taking up space.
$(document).ready(function() {
window.print();
});
#media print {
.barcode-container {
display: block !important;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="subpage">
<div class="barcode-container">
<div style="font-size:0;position:relative;width:422px;height:30px;">
<div style="background-color:black;width:4px;height:30px;position:absolute;left:0px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:6px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:16px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:22px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:28px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:36px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:44px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:50px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:56px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:66px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:74px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:82px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:88px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:94px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:100px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:110px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:116px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:124px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:132px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:138px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:146px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:154px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:160px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:168px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:176px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:182px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:190px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:198px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:204px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:212px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:220px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:226px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:234px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:242px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:248px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:256px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:264px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:272px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:280px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:286px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:292px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:300px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:308px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:314px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:324px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:330px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:336px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:344px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:352px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:358px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:368px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:374px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:382px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:390px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:396px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:406px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:414px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:418px;top:0px;"> </div>
<div style="background-color:black;width:0px;height:30px;position:absolute;left:422px;top:0px;"> </div>
<div style="background-color:black;width:0px;height:30px;position:absolute;left:422px;top:0px;"> </div>
</div>
</div>
<p class="bold">ID: 60105</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus luctus volutpat lorem a auctor. In lorem nisi, vulputate vel dapibus eu, tristique non lacus. Proin maximus nulla a imperdiet accumsan. Nullam diam tortor, hendrerit a libero vel, placerat
ullamcorper urna. Vivamus consequat placerat lectus, mattis porttitor felis feugiat non. Quisque non elementum est. Quisque semper tincidunt nunc quis condimentum. Morbi tristique ipsum quis velit accumsan tincidunt. Etiam et imperdiet ex, at posuere
enim. Curabitur vitae lacinia libero.</p>
</div>
I tried to do a display: block !important; to the barcode container but it still didn't print it. Any ideas?
Background colours don't print by default. They are set as transparent.
Try:
box-shadow: inset 0 0 0 10000px #000; /*Fake Bg*/
Alternatively the user can set:
Tick 'Print Background Colours and Images' from your browsers 'Page Setup'
You may also use:
-webkit-print-color-adjust: exact;
but this is only supported in Chrome (And other Webkit browsers).
The Chrome css property "-webkit-print-color-adjust: exact;" will make it work appropriately in chrome.
$(document).ready(function() {
window.print();
});
#media print {
.barcode-container>div{
display: block !important;
-webkit-print-color-adjust: exact;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="subpage">
<div class="barcode-container">
<div style="font-size:0;position:relative;width:422px;height:30px;">
<div style="background-color:black;width:4px;height:30px;position:absolute;left:0px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:6px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:16px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:22px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:28px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:36px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:44px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:50px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:56px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:66px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:74px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:82px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:88px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:94px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:100px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:110px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:116px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:124px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:132px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:138px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:146px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:154px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:160px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:168px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:176px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:182px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:190px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:198px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:204px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:212px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:220px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:226px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:234px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:242px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:248px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:256px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:264px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:272px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:280px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:286px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:292px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:300px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:308px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:314px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:324px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:330px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:336px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:344px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:352px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:358px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:368px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:374px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:382px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:390px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:396px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:406px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:414px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:418px;top:0px;"> </div>
<div style="background-color:black;width:0px;height:30px;position:absolute;left:422px;top:0px;"> </div>
<div style="background-color:black;width:0px;height:30px;position:absolute;left:422px;top:0px;"> </div>
</div>
</div>
<p class="bold">ID: 60105</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus luctus volutpat lorem a auctor. In lorem nisi, vulputate vel dapibus eu, tristique non lacus. Proin maximus nulla a imperdiet accumsan. Nullam diam tortor, hendrerit a libero vel, placerat
ullamcorper urna. Vivamus consequat placerat lectus, mattis porttitor felis feugiat non. Quisque non elementum est. Quisque semper tincidunt nunc quis condimentum. Morbi tristique ipsum quis velit accumsan tincidunt. Etiam et imperdiet ex, at posuere
enim. Curabitur vitae lacinia libero.</p>
</div>
You can use -webkit-print-color-adjust: exact; on Chrome and color-adjust: exact; on Firefox
$(document).ready(function() {
window.print();
});
#media print {
.barcode-container {
display: block !important;
-webkit-print-color-adjust: exact;
color-adjust: exact;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="subpage">
<div class="barcode-container">
<div style="font-size:0;position:relative;width:422px;height:30px;">
<div style="background-color:black;width:4px;height:30px;position:absolute;left:0px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:6px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:16px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:22px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:28px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:36px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:44px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:50px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:56px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:66px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:74px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:82px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:88px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:94px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:100px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:110px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:116px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:124px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:132px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:138px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:146px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:154px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:160px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:168px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:176px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:182px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:190px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:198px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:204px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:212px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:220px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:226px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:234px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:242px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:248px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:256px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:264px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:272px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:280px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:286px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:292px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:300px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:308px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:314px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:324px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:330px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:336px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:344px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:352px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:358px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:368px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:374px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:382px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:390px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:396px;top:0px;"> </div>
<div style="background-color:black;width:6px;height:30px;position:absolute;left:406px;top:0px;"> </div>
<div style="background-color:black;width:2px;height:30px;position:absolute;left:414px;top:0px;"> </div>
<div style="background-color:black;width:4px;height:30px;position:absolute;left:418px;top:0px;"> </div>
<div style="background-color:black;width:0px;height:30px;position:absolute;left:422px;top:0px;"> </div>
<div style="background-color:black;width:0px;height:30px;position:absolute;left:422px;top:0px;"> </div>
</div>
</div>
<p class="bold">ID: 60105</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus luctus volutpat lorem a auctor. In lorem nisi, vulputate vel dapibus eu, tristique non lacus. Proin maximus nulla a imperdiet accumsan. Nullam diam tortor, hendrerit a libero vel, placerat
ullamcorper urna. Vivamus consequat placerat lectus, mattis porttitor felis feugiat non. Quisque non elementum est. Quisque semper tincidunt nunc quis condimentum. Morbi tristique ipsum quis velit accumsan tincidunt. Etiam et imperdiet ex, at posuere
enim. Curabitur vitae lacinia libero.</p>
</div>
Re: Bootstrap 3.3.5 in Wordpress
I have not seen this issue before. All I want to do is align 3 x .col-md-4 .wells inside a row, but they just won't align. The first div is always a bit higher; see screenshot.
This is the code:
<div class="row">
<div class="col-xs-12 col-sm-10 col-sm-offset-1 col-md-4 col-md-offset-0 col-lg-4 col-lg-offset-0 text-center">
<a class="page-scroll" href="#how-to"><div class="home-plans well">
<br/>
<h2>1.</h2>
<p class="lead text-left">Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo.p>
</div> <!-- /well --></a>
</div> <!-- /col-md-4 -->
<div class="col-xs-12 col-sm-10 col-sm-offset-1 col-md-4 col-md-offset-0 col-lg-4 col-lg-offset-0 text-center">
<div class="home-plans well">
<br />
<h2>2.</h2>
<p class="lead text-left">Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo.p>
</div> <!-- /well -->
</div> <!-- /col-md-4 -->
<div class="col-xs-12 col-sm-10 col-sm-offset-1 col-md-4 col-md-offset-0 col-lg-4 col-lg-offset-0 text-center">
<div class="home-plans well">
<br />
<h2>3.</h2>
<p class="lead text-left">Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo.</p>
</div> <!-- /well -->
</div> <!-- /col-md-4 -->
</div>
Using f12 tools in explorer, the issue seems to be the below CSS code styling the row:
/*media all*/
.btn-group-vertical > .btn-group::after, .btn-group-vertical > .btn-group::before, .btn-toolbar::after, .btn-toolbar::before, .clearfix::after, .clearfix::before, .container-fluid::after, .container-fluid::before, .container::after, .container::before, .dl-horizontal dd::after, .dl-horizontal dd::before, .form-horizontal .form-group::after, .form-horizontal .form-group::before, .modal-footer::after, .modal-footer::before, .nav::after, .nav::before, .navbar-collapse::after, .navbar-collapse::before, .navbar-header::after, .navbar-header::before, .navbar::after, .navbar::before, .pager::after, .pager::before, .panel-body::after, .panel-body::before, .row::after, .row::before {
display: table;
content: " ";
}
This page is in Wordpress. I have tried the same code in a normal HTML page and the .well .col-md-4s align OK.
To get the cols to align I can just remove the row, but I want to use rows.
This has been killing me for nearly one day now. I have done loads of research and tried using clearfix and clear: both all over without joy. Can anyone shed some light on this please?
Edit: I also note that the two rows in the footer section are causing the page footer to have a scroll bar? So, I have had to remove those rows too. It seems that I can't use rows in Wordpress with Bootstrap anymore for some reason.
Hmm, it's really tricky to say without seeing more of the CSS but have you tried reformatting your first div as follows:
<div class="col-xs-12 col-sm-10 col-sm-offset-1 col-md-4 col-md-offset-0 col-lg-4 col-lg-offset-0 text-center">
<div class="home-plans well">
<a class="page-scroll" href="#how-to">
<br/>
<h2>1.</h2>
<p class="lead text-left">Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo.p>
</a>
</div> <!-- /well -->
</div> <!-- /col-md-4 -->
Then styling the inner anchor element as follows:
CSS:
.well > a {
display: block;
}
I'd guess that it's something to do with the anchor element wrapping around the .well div?
I had four containers with four inner divs, floated left with auto height.
<div class="box">
<div class="head">
Heading text
</div>
<div class="image">
Image
</div>
<div class="text">
Integer posuere erat a ante venenatis dapibus posuere velit aliquet.
</div>
<div class="link">Link text</div>
.box{
width: 150px;
float: left;
}
Complete jsFiddle:
http://jsfiddle.net/H8w32/
To make the inner divs height the same througout all of the four containers, I changed the floated layout, and used display:table instead.
<div class="table">
<div class="row head">
<div class="cell">Heading text</div>
<div class="cell">Here is a lot longer heading text to examplify</div>
<div class="cell">Heading text</div>
<div class="cell">Heading text</div>
</div>
<div class="row image">
<div class="cell">Image</div>
<div class="cell">Image</div>
<div class="cell">Image</div>
<div class="cell">Image</div>
</div>
<div class="row text">
<div class="cell">Integer posuere erat a ante venenatis dapibus posuere velit aliquet.</div>
<div class="cell">Integer posuere erat a ante venenatis dapibus posuere velit aliquet.</div>
<div class="cell">Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Integer posuere erat a ante. Dapibus posuere velit aliquet.</div>
<div class="cell">Integer posuere erat a ante venenatis dapibus posuere velit aliquet.</div>
</div>
<div class="row link">
<div class="cell">Link text</div>
<div class="cell">Link text</div>
<div class="cell">Link text</div>
<div class="cell">Link text</div>
</div>
</div>
-
.table{
display: table;
}
.row{
display: table-row;
}
.cell{
display: table-cell;
width: 150px;
}
http://jsfiddle.net/Wh7Pm/1/
This looks exactly like I wanted it to. But now I lost the perks from using float, specifically the ability to add more containers and that they automatically got pushed in to the next "row", or that they get pushed to a new row if the viewport is too small to fit them. The containers are added to the same "row" if I add more containers to my display:table layout.
Is this possible to solve? I want the behaviour from both display:table (equal height of heading divs and text divs) and float:left.
Not possible currently without using javascript to set heights. You may want to look into the spec for CSS flexible boxes, which is the real CSS-only solution to this problem.
https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes
Adoption of flexbox is still in the early stages, but if you're building a cutting edge app that targets mostly modern browsers, you may be able to get away with it.
I am writing a basic website in HTML5, i have all the site structure in place and so far everything has been working well.
However I have one section that seem to go off on its own a bit.
as soon as I had a height to the section the sections moves to the top of the article behind the top two section where the actual content within the section stays in place.
<article><section class="welcome-box">
<section class="welcome-wrapper">
<div class="welcome-hello">
<div class="welcome-hellotext">HELLO, WELCOME TO SAA RECRUITMENT </div>
</div>
<div class="welcome-line"></div>
<div class="welcome-textbox">
<div class="welcome-textboxtext">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.</div>
</div>
<div class="welcome-button">
<div class="welcome-buttontext">READ MORE</div>
</div>
</section>
</section>
<section class="home-slider">
<div class="slider-wrapper">
<div id="slider">
<div class="slide1">
<img src="images/slide_1.jpg" alt="" />
</div>
<div class="slide2">
<img src="images/slide_2.jpg" alt="" />
</div>
<div class="slide3">
<img src="images/slide_3.jpg" alt="" />
</div>
<div class="slide4">
<img src="images/slide_4.jpg" alt="" />
</div>
</div>
<div id="slider-direction-nav"></div>
<div id="slider-control-nav"></div>
</div>
</section>
<!-- Slider Script -->
<script type="text/javascript">
$(document).ready(function() {
var slider = $('#slider').leanSlider({
directionNav: '#slider-direction-nav',
controlNav: '#slider-control-nav'
});
});
</script>
<!-- End Slider Script -->
<section class="about-box">
<div class="about-boxtitle">TITLE HERE</div>
<div class="about-boxline"></div>
<div class="about-boxtext"></div>
</section>
<section class="news-box">
<div class="news-boxtitle">NEWS</div>
<div class="news-boxline"></div>
<div class="news-boxtext"></div>
</section>
<section class="clients-box">
<div class="clients-boxtitle">CLIENTS</div>
<div class="clients">client</div>
<div class="clients">client</div>
<div class="clients">client</div>
</section>
</article>
The section I am having trouble with is the one with a class of "clients-box" (very last section)
Here is the CSS:
.clients-box {
width: 960px;
margin-top: 10px;
background-color: #FFF;
}
ul.clients {
width: 940px;
height: 40px;
margin: 0 auto 0;
}
ul.clients li.client {
width: 150px;
height: 40px;
display: inline-block;
background-color: #039;
clear: both;
The website is live here: http://dev.saarecruitment.com/
.clients-box needs either float: left or float: right. You can add margin: 10px auto to center it with 10px top/bottom margins.
You have used float on all the above <sections> which means that they are not occupying space. Thus this box got to the top, under the floated elements.
Easiest way would be to apply a float: left to this box as well.
An alternative method, inspired by #Mr. Alien would be to just apply clear:left to this block.