我有一个html / css块,用于显示图像并叠加颜色<div>
和文本。
我想让后台<img>
能够在不扩展容器(bootstrap col)的情况下进行缩放。
我尝试使用mouseenter
和mouseleave
事件在jQuery中添加一个新类,并在max-width
元素中使用CSS max-height
和img
但是图像当放大时,静止图像会延伸到容器之外。
任何提示?
<script>
$(document).ready(function(){
$(".category").mouseenter(function(){
$(this).prevAll('img').first().addClass("img-category-zoom");
});
$(".category").mouseleave(function(){
$(this).prevAll('img').first().removeClass("img-category-zoom");
});
});
</script>
<style>
.category {
position: absolute;
top: 0px; left: 0px;
z-index: 3;
width: 100%; height: 100%;
background: rgba(172, 44, 48, 0.85);
color: white;
border-style: solid;
border-width: 1px;
border-color: rgba(172, 44, 48, 0);
}
.category:hover {
border-style: solid;
border-width: 1px;
border-color: white;
}
.img-category {
position: relative; z-index: 2;
width: 100%; height: 100%;
max-width: 100%; max-height: 100%;
transition: all 0.5s ease;
}
.img-category-zoom {
transform: scale(1.2);
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="page">
<div class="container-fluid">
<div class="content row">
<div class="no-padding col-lg-6 col-md-6 col-sm-6 col-xs-6 even">
<img src="http://via.placeholder.com/50x50" alt="" class="img-category img-responsive">
<div class="category">OVERLAY</div>
</div>
</div>
</div>
</div>
答案 0 :(得分:1)
您可以将<?php
require 'vendor/autoload.php';
$fullpage = '
<html>
<head>
<title>Base64 Test</title>
</head>
<body>
<h1>Title of Test Document</h1>
<img src="data:image/png;base64,R0lGODlhPQBEAPeoAJosM//AwO/AwHVYZ/z595kzAP/s7P+goOXMv8+fhw/v739/f+8PD98fH/8mJl+fn/9ZWb8/PzWlwv///6wWGbImAPgTEMImIN9gUFCEm/gDALULDN8PAD6atYdCTX9gUNKlj8wZ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mS43PmGoIiKUUEGkMEC/PJHgxw0xH74yx/3XnaYRJgMB8obxQW6kL9QYEJ0FIFgByfIL7/IQAlvQwEpnAC7DtLNJCKUoO/w45c44GwCXiAFB/OXAATQryUxdN4LfFiwgjCNYg+kYMIEFkCKDs6PKAIJouyGWMS1FSKJOMRB/BoIxYJIUXFUxNwoIkEKPAgCBZSQHQ1A2EWDfDEUVLyADj5AChSIQW6gu10bE/JG2VnCZGfo4R4d0sdQoBAHhPjhIB94v/wRoRKQWGRHgrhGSQJxCS+0pCZbEhAAOw==" />
<p>End of document.</p>
</body>
</html>
';
use Dompdf\Dompdf;
use Dompdf\Options;
$options = new Options();
$options->setDpi(96);
$options->set('isHtml5ParserEnabled', true);
$options->set('isRemoteEnabled', true);
$options->set('debugKeepTemp', true);
$dompdf = new Dompdf($options);
$dompdf->loadHtml($fullpage);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$dompdf->stream("Report.pdf", array( 'Attachment'=>0));
?>
添加到容器div
overflow: hidden
&#13;
$(document).ready(function(){
$(".category").mouseenter(function(){
$(this).prevAll('img').first().addClass("img-category-zoom");
});
$(".category").mouseleave(function(){
$(this).prevAll('img').first().removeClass("img-category-zoom");
});
});
&#13;
.category {
position: absolute;
top: 0px; left: 0px;
z-index: 3;
width: 100%; height: 100%;
background: rgba(172, 44, 48, 0.85);
color: white;
border-style: solid;
border-width: 1px;
border-color: rgba(172, 44, 48, 0);
}
.category:hover {
border-style: solid;
border-width: 1px;
border-color: white;
}
.img-category {
position: relative; z-index: 2;
width: 100%; height: 100%;
max-width: 100%; max-height: 100%;
transition: all 0.5s ease;
}
.img-category-zoom {
transform: scale(1.2);
}
/* Add this */
.col-lg-6, .col-md-6, .col-sm-6, .col-xs-6 {
overflow: hidden;
}
&#13;