MVC Print Page break not working, contents are cut off - html

I tried below code to break the page while printing however its not working, I learnt that the Page break won't work in nested div tags, I 'm not sure how to achieve this, basically I 'm trying to display images, so in a row there will be 4 or more than that based on the display size of screen however at the time of printing it should print 4 images in a row and the next 4 images should be printed in next page as if now while printing, the images and the contents are getting cut off, please help
<div class='row small'>
#foreach (var item in Model.BuyerList.ImageList)
{
<div class="card bg-light mb-3 mr-1 card-text-fixed-width" style='page-break-after:always'>
<div class="img-control">
#if (!string.IsNullOrWhiteSpace(item.ImageUrl))
{
<img src="#item.ImageUrl" style="height:150px;" class="card-img-top" alt="Card image" />
}
else
{
<img src="~/AdTrack Images/NoProductImage.png" style="height:150px;" class="card-img-top" alt="Card image" />
}
<div class="edit d-print-none">
<a data-toggle="modal"
data-id='{"id": "#item.Items.Number","ItemId":"#item.Items.ItemId", "AdId":"#item.Header.Id"}'
class="open-AddBookDialog btn btn-primary" href="#"><i class="fa fa-pencil fa-lg"></i></a>
</div>
<div class="delete d-print-none">
<a data-toggle="modal" data-id='{"id": "#item.Items.Number","ItemId":"#item.Items.Id", "AdId":"#item.Id"}'
class="open-delete btn btn-primary" href="#">
<i class="fa fa-trash" style="font-size:15px;color:red" id="delete" name="delete"></i>
</a>
</div>
<div class="edit d-print-none">
<a data-toggle="modal"
data-id='{"id": "#item.Items.Number","ItemId":"#item.Items.ItemId", "AdId":"#item.Header.Id"}'
class="open-AddBookDialog btn btn-primary" href="#"><i class="fa fa-info-circle fa-lg"></i></a>
</div>
}
</div>
<div class="card-header">
<div class="font-weight-bold">Page #Html.DisplayFor(modelItem => item.Number)- #Html.DisplayFor(modelItem => item.Business)</div>
<div class="row mb-2 font-weight-bold">
<div class="col-md-6">Cut: #Html.DisplayFor(modelItem => item.Items.Number)</div>
<div class="col-md-6 text-right">9-Box: #Html.DisplayFor(modelItem => item.Items.BoxNumber)</div>
</div>
<div class="row mb-2 font-weight-bold">
<div class="col-md-4">Group #Html.DisplayFor(modelItem => item.Department.Test)</div>
#*<div class="col-md-4">Div: #Html.DisplayFor(modelItem => item.Department.Division)</div>*#
<div class="col-md-4">Buyer #Html.DisplayFor(modelItem => item.Department.Test)</div>
<div class="col-md-4">Dept #Html.DisplayFor(modelItem => item.Items.Department)</div>
</div>
</div>
</div>
}
</div>

Add wrap div with style='page-break-after:always'.
<div class='row small'>
#foreach (var item in Model.BuyerList.ImageList)
{
<div style='page-break-after:always'>
<div class="card bg-light mb-3 mr-1 card-text-fixed-width" >
<div class="img-control">
#if (!string.IsNullOrWhiteSpace(item.ImageUrl))
{
<img src="#item.ImageUrl" style="height:150px;" class="card-img-top" alt="Card image" />
}
else
{
<img src="~/AdTrack Images/NoProductImage.png" style="height:150px;" class="card-img-top" alt="Card image" />
}
<div class="edit d-print-none">
<a data-toggle="modal"
data-id='{"id": "#item.Items.Number","ItemId":"#item.Items.ItemId", "AdId":"#item.Header.Id"}'
class="open-AddBookDialog btn btn-primary" href="#"><i class="fa fa-pencil fa-lg"></i></a>
</div>
<div class="delete d-print-none">
<a data-toggle="modal" data-id='{"id": "#item.Items.Number","ItemId":"#item.Items.Id", "AdId":"#item.Id"}'
class="open-delete btn btn-primary" href="#">
<i class="fa fa-trash" style="font-size:15px;color:red" id="delete" name="delete"></i>
</a>
</div>
<div class="edit d-print-none">
<a data-toggle="modal"
data-id='{"id": "#item.Items.Number","ItemId":"#item.Items.ItemId", "AdId":"#item.Header.Id"}'
class="open-AddBookDialog btn btn-primary" href="#"><i class="fa fa-info-circle fa-lg"></i></a>
</div>
}
</div>
<div class="card-header">
<div class="font-weight-bold">Page #Html.DisplayFor(modelItem => item.Number)- #Html.DisplayFor(modelItem => item.Business)</div>
<div class="row mb-2 font-weight-bold">
<div class="col-md-6">Cut: #Html.DisplayFor(modelItem => item.Items.Number)</div>
<div class="col-md-6 text-right">9-Box: #Html.DisplayFor(modelItem => item.Items.BoxNumber)</div>
</div>
<div class="row mb-2 font-weight-bold">
<div class="col-md-4">Group #Html.DisplayFor(modelItem => item.Department.Test)</div>
#*<div class="col-md-4">Div: #Html.DisplayFor(modelItem => item.Department.Division)</div>*#
<div class="col-md-4">Buyer #Html.DisplayFor(modelItem => item.Department.Test)</div>
<div class="col-md-4">Dept #Html.DisplayFor(modelItem => item.Items.Department)</div>
</div>
</div>
</div>
</div>
}
</div>

I had a similar problem, but I achieved it using CSS. Simply add a css class and give it width in percentage. For example, 30% if you want to display 3 pictures or 19% if you want to display 4 and you can also set margin accordingly if you want spaces between the images. In this way, the images would resize themselves accordingly no matter what screen size is.
Example:
img {
width: 30%;
float: left;
margin: 1.66%;
}
Please refer to this code pen link also: https://codepen.io/alinaalam/pen/YeLqWm

Related

Bootstrap 5 Vertical Alignment issue with responsive

I have a issue with vertical alignment in a container. I have the following code that does what I want, that is, the first row in the center and the second at the bottom of the container.
Full screen
<header class="masthead" id="home">
<div class="container h-100">
<div class="row h-100 align-items-center justify-content-evenly text-center">
<div class="col-4">
<img src="assets/img/profil.png" class="rounded-circle img-fluid" alt="...">
<hr class="divider" />
<h1 class="text-white font-weight-bold">d3vyce</h1>
</div>
<div class="col-md-8 col-lg-4">
<h2 class="text-white font-weight-bold">Hi 👋, Welcome to my Site!</h2>
<p class="text-white">Developer, CTF Player, Homelab, 3D Printing</p>
<hr class="divider" />
<div class="d-grid col-6 mx-auto">
<a class="btn btn-outline-light btn-lg" href="https://blog.d3vyce.fr" target="_blank"><i class="fa fa-bookmark fa-lg"></i> Blog</a>
<a class="btn mt-2 btn-outline-light btn-lg" href="https://github.com/d3vyce" target="_blank"><i class="fa fa-github fa-lg"></i> Github</a>
</div>
</div>
</div>
<div class="row head-row justify-content-center">
<div class="col-12 mouse_scroll p-0">
<a href="#about">
<div class="mouse">
<div class="wheel"></div>
</div>
<div>
<span class="m_scroll_arrows unu"></span>
<span class="m_scroll_arrows doi"></span>
<span class="m_scroll_arrows trei"></span>
</div>
</a>
</div>
</div>
</div>
</header>
For the alignment at the bottom of the second row I use the following CSS:
.mouse_scroll {
display: block;
width: 24px;
height: 100px;
position: absolute;
bottom: 0; }
The problem happens with the responsive. The columns of the first row are well one on top of the other, but the space between the two is much too important and I can't modify it :(
I tried to search on stackoverflow for answers, but after many tests I'm in a dead end...
Reponsive
Thank you in advance for your answers!

CSS selector of inner elements

I'm want to select the words "Dashboard", "Attendance", "Marcum" and "Results" and set their color to White.
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="fpstartwrap">
<div class="fpstart">
<div class="iconset">
<div class="btn btn-secondary">
<a role="button" href="https://rafiee.net" title="Dashboard"
alt="Dashboard" target="_blank">
<div class="navicon" align="center">
<i class="fa fa-3x fa-home"></i>
</div>
Dashboard
</a>
</div>
<div class="btn btn-secondary">
<a role="button" href="https://rafiee.net/attendance"
title="Attendance" alt="Attendance" target="_blank">
<div class="navicon" align="center">
<i class="fa fa-3x fa-user-times"></i>
</div>
Attendance
</a>
</div>
<div class="btn btn-secondary">
<a role="button" href="https://rafiee.net/q" title="Marcum"
alt="Marcum" target="_parent">
<div class="navicon" align="center">
<i class="fa fa-3x fa-calculator"></i>
</div>
Marcum
</a>
</div>
<div class="btn btn-secondary">
<a role="button" href="https://rafiee.net/user/" title="Results"
alt="Results" target="_self">
<div class="navicon" align="center">
<i class="fa fa-3x fa-id-card-o"></i>
</div>
Results
</a>
</div>
</div>
</div>
</div>
<div class="collapse" id="fpslider">
<div class="row">
<div class="col-md-3">
<a class="btn btn-primary" href="https://rafiee.net">Rafiee.net</a>
</div>
<div class="col-md-3">
<a class="btn btn-primary" href="https://rafiee.net/attendance">Attendance</a>
</div>
<div class="col-md-3">
<a class="btn btn-primary" href="https://rafiee.net/dailybonus">Daily Bonus</a>
</div>
<div class="col-md-3">
<a class="btn btn-primary" href="https://rafiee.net/q">Marcum Calculator</a>
</div>
</div>
</div>
<div style="clear:both;"></div>
</div>
</div>
</div>
I tried to do it by :
div a[role="button"] {
color: white;
}
However, since I have other elements with role "Button", they are all changed to white which is undesirable in my case. I only need to target these four words. Is it possible? Any help is appreciated in advance.
Thanks
Use the parent elements in the selector to be more specific:
.fpstartwrap > .fpstart > .iconset > div.btn.btn-secondary a[role="button"] {
color: white;
}
Or simply apply a class to those buttons which you only use for these four buttons and use that class in your selector.
To get a CSS selector to only act on a button inside a div use > this tells CSS to get all elements that have a parent div and role=button:
div > a[role="button"] {
color: white;
}
if you really need to be specific then you can even just add a special class to the buttons you wanna act on like
<a class="whiteButton" role="button" href="https://rafiee.net/attendance" title="Attendance" alt="Attendance" target="_blank">
Then for the CSS you can do
.whiteButton {
}
or if only whiteButton inside of div's
div > .whiteButton {
}
or even
div > a > .whiteButton {
}
div > a[role="button"]{
color: white;
background: blue;
}
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="fpstartwrap">
<div class="fpstart">
<div class="iconset">
<div class="btn btn-secondary">
<a role="button" href="https://rafiee.net" title="Dashboard"
alt="Dashboard" target="_blank">
<div class="navicon" align="center">
<i class="fa fa-3x fa-home"></i>
</div>
Dashboard
</a>
</div>
<div class="btn btn-secondary">
<a role="button" href="https://rafiee.net/attendance"
title="Attendance" alt="Attendance" target="_blank">
<div class="navicon" align="center">
<i class="fa fa-3x fa-user-times"></i>
</div>
Attendance
</a>
</div>
<div class="btn btn-secondary">
<a role="button" href="https://rafiee.net/q" title="Marcum"
alt="Marcum" target="_parent">
<div class="navicon" align="center">
<i class="fa fa-3x fa-calculator"></i>
</div>
Marcum
</a>
</div>
<div class="btn btn-secondary">
<a role="button" href="https://rafiee.net/user/" title="Results"
alt="Results" target="_self">
<div class="navicon" align="center">
<i class="fa fa-3x fa-id-card-o"></i>
</div>
Results
</a>
</div>
</div>
</div>
</div>
<div class="collapse" id="fpslider">
<div class="row">
<div class="col-md-3">
<a class="btn btn-primary" href="https://rafiee.net">Rafiee.net</a>
</div>
<div class="col-md-3">
<a class="btn btn-primary" href="https://rafiee.net/attendance">Attendance</a>
</div>
<div class="col-md-3">
<a class="btn btn-primary" href="https://rafiee.net/dailybonus">Daily Bonus</a>
</div>
<div class="col-md-3">
<a class="btn btn-primary" href="https://rafiee.net/q">Marcum Calculator</a>
</div>
</div>
</div>
<div style="clear:both;"></div>
</div>
</div>
</div>

How do I make the images show the same height? bootstrap 4

it shows up like that because my photo is not the same size, is there a solution for this problem?
enter image description here
here is the code:
<div class="features_items"><!--features_items-->
<h2 class="title text-center">Features Items</h2>
#foreach($products as $product)
<div class="col-sm-4 h-100">
<div class="product-image-wrapper ">
<div class="single-products h-100">
<div class="productinfo h-100 text-center">
<img src="{{$baseUrl . $product->feature_image_path}}" alt="" />
<h2>{{ number_format($product->price )}} VNĐ</h2>
<p>{{ $product->name }}</p>
<a href="#"
data-url="{{route('addToCart',['id'=> $product->id])}}"
class="btn btn-default add_to_cart">
<i class="fa fa-shopping-cart"></i>
Add to cart
</a>
</div>
<div class="product-overlay">
<div class="overlay-content">
<h2>{{ number_format($product->price )}} VNĐ</h2>
<p>{{ $product->name }}</p>
<button
data-url="{{route('addToCart',$product->id)}}"
class="btn btn-default add_to_cart"><i class="fa fa-shopping-cart"></i>Add to cart</button>
</div>
</div>
</div>
</div>
</div>
#endforeach
</div><!--features_items-->

Using Materialize.min.css for cards but can't size them to fixed and can't show them in a single row

Using Materialize.min.css for creating material cards
Can't align multiple cards in a signle row (side by side)
Another problem I'm facing is that I can't make the cards of fixed size. Resizing the browser window makes them unusable at some point.
Reference Screenshots
My Code: https://pastebin.com/uu2YgdGK
Try on JSbin
Bro Use this code to fix
Use materialize css classes and use media query to set site
responsive.
Use m12 on main div instead of m2
Use m2 class on card div
Final check code and Run Snippet
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" />
<style>
.card-image {
max-height: 100% !important;
}
.card.small {
height: auto !important;
}
#media(max-width: 1199px) {
.card {
width: 20% !important;
}
}
#media(max-width: 1024px) {
.card {
width: 33.33% !important;
}
}
#media(max-width: 625px) {
.card {
width: 50% !important;
}
}
#media(max-width: 414px) {
.card {
width: 100% !important;
}
}
</style>
</head>
</html>
<body>
<div class="row">
<div class="col s12 m12">
<!--<div class='md-padding' layout="row" layout-wrap>-->
<!--<div class="container">-->
<div class="card small col m2">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="https://fbdev.mpsecure.com/groupon/201301_dir/images/upload/1363923993_tmplogo_wolf_1.jpg">
</div>
<div class="card-content">
<span class="card-title activator grey-text text-darken-4">Bharatiya Janta party
<button class="btn waves-effect waves-light right" type="submit" name="vote1">VOTE</button>
</span>
<!--<p>This is a link</p>-->
</div>
</div>
<div class="card small col m2">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="https://fbdev.mpsecure.com/groupon/201301_dir/images/upload/1363923993_tmplogo_wolf_1.jpg">
</div>
<div class="card-content">
<span class="card-title activator grey-text text-darken-4">Bharatiya Janta party
<button class="btn waves-effect waves-light right" type="submit" name="vote1">VOTE</button>
</span>
</div>
</div>
<div class="card small col m2">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="https://fbdev.mpsecure.com/groupon/201301_dir/images/upload/1363923993_tmplogo_wolf_1.jpg">
</div>
<div class="card-content">
<span class="card-title activator grey-text text-darken-4">Bharatiya Janta party
<button class="btn waves-effect waves-light right" type="submit" name="vote1">VOTE</button>
</span>
<!--<p>This is a link</p>-->
</div>
</div>
<div class="card small col m2">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="https://fbdev.mpsecure.com/groupon/201301_dir/images/upload/1363923993_tmplogo_wolf_1.jpg">
</div>
<div class="card-content">
<span class="card-title activator grey-text text-darken-4">Bharatiya Janta party
<button class="btn waves-effect waves-light right" type="submit" name="vote1">VOTE</button>
</span>
</div>
</div>
<div class="card small col m2">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="https://fbdev.mpsecure.com/groupon/201301_dir/images/upload/1363923993_tmplogo_wolf_1.jpg">
</div>
<div class="card-content">
<span class="card-title activator grey-text text-darken-4">Bharatiya Janta party
<button class="btn waves-effect waves-light right" type="submit" name="vote1">VOTE</button>
</span>
<!--<p>This is a link</p>-->
</div>
</div>
<div class="card small col m2">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="https://fbdev.mpsecure.com/groupon/201301_dir/images/upload/1363923993_tmplogo_wolf_1.jpg">
</div>
<div class="card-content">
<span class="card-title activator grey-text text-darken-4">Bharatiya Janta party
<button class="btn waves-effect waves-light right" type="submit" name="vote1">VOTE</button>
</span>
</div>
</div>
<!--</div>-->
<!--</div>-->
</div>
</div>
</body>

carousel slider displays single item in Angular4

Working in an Angular4 project in this ,I have used carousel for displaying products,Products are binding from API response .
In my carousel I display the products like single row 3 column format ,If API returns 10 products the 10 th product is get displayed single slide .
I want to merge the 10th product with 1st and 2nd product then display like a 3 column slide .
Html
<div class="col-sm-9">
<section class="container">
<div class="row">
<div class="col-sm-1">
<i class="fa fa-user" style="font-size:25px"></i>
</div>
<div class="col-sm-9">
<h5>Popular Products</h5>
</div>
</div>
</section>
<hr>
<section class="carousel slide" id="myCarousel">
<div class="container">
<div class="row">
<div class="col-sm-12 text-right mb-4">
<a class="btn btn-outline-secondary carousel-control left" href="#myCarousel" data-slide="prev" title="go back">
<i class="fa fa-lg fa-chevron-left"></i>
</a>
<a class="btn btn-outline-secondary carousel-control right" href="#myCarousel" data-slide="next" title="more">
<i class="fa fa-lg fa-chevron-right"></i>
</a>
</div>
</div>
</div>
<div class="container p-t-0 m-t-2 carousel-inner">
<div class="row row-equal carousel-item {{ i == 0 ? 'active' : '' }} m-t-0" *ngFor="let chunkProducts of productData;let i =index;">
<div class="col-sm-4" *ngFor="let slider of chunkProducts;">
<div class="card">
<div class="card-img-top card-img-top-250 one">
<img class="img-fluid" [src]="slider['PRODUCT_IMAGE']" alt="Carousel 1">
<img routerLink="/my-cart" class="img-fluid two" [src]="slider['PRODUCT_IMAGE_ONHOVER']" alt="Carousel 1">
</div>
<div class="card-block pt-2">
<div class="col-sm-12 text-center card-text">
<span>{{slider.PRODUCT_NAME}}</span>
<br>
<input type="hidden" value="{{slider.PRODUCT_ID}}" #Pname1>
<br>
<span>{{slider.PRODUCT_PRICE}}</span>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
This is my html file to show the slide as 3 column format.
Component
ngOnInit() {
this.CartdataService.get_New_Products().subscribe(
data => {
this.productData = this.chunks(data,3);
console.log(this.productData);
});
chunks(array, size) {
let results = [];
results = [];
while (array.length) {
results.push(array.splice(0, size));
}
return results;
}
Just Change :
this.CartdataService.get_New_Products().subscribe(data => {
this.productData = this.chunks(data.json(),3);
let last = this.productData[this.productData.length-1].length;
if(this.productData.length > 1 && last < 3) {
this.productData[this.productData.length-1] = [ ...this.productData[this.productData.length-1] , ...this.productData[0].slice(0, 3-last) ];
}
});
WORKING DEMO