可以通过添加负边距来防止图像具有未定义的模糊边缘,但是在CSS转换期间,这会失败.在添加或删除过滤器模糊类时,如何保持CSS过渡期间定义的图像边缘?
测试中:
看看我的例子:Codepen
HTML:
<link href='http://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Hind' rel='stylesheet' type='text/css'>
<div class="container">
<img class="blur" src="http://budgetstockphoto.com/bamers/stock_photo_spectrum.jpg"/>
</div>
<div class="col">
<h2 class="montserrat">Hover Over Image</h2>
<hr>
<p class="hind">Preventing an image from having undefined blurry edges can be achieved by adding negative margin, but during a CSS transition this fails. As you can see, on-hover, the edges of the image become undefined/blurred. How can you keep the edges of an image defined during a CSS transition …Run Code Online (Sandbox Code Playgroud) 问题:我想在类中永久设置私有变量,然后使用类外部的getter函数访问它们.问题是每次我实例化一个新的类并创建一个对象时它会破坏先前设置的变量.在提供的示例中,我不想通过调用函数"getAgain"传递对象.我想简单地访问globalVars类而不破坏任何设置变量.我知道通过创建一个'新对象'本质上会破坏当前不是静态的变量.所以:
我担心我不会以正确的方式接近这一点,或者我的方法论存在缺陷.
<?php
class globalVars{
private $final = "Default Foo </br>";
public function setter($param){
$this->final = $param;
}
public function getter(){
return $this->final;
}
}
class driver{
function __construct($param){
$globalVars = new globalVars();
$globalVars->setter($param);
$val = $globalVars->getter();
echo $val;
$this->getAgain();
}
function getAgain(){
$globalVars = new globalVars();
$val = $globalVars->getter();
echo $val;
}
}
$input = "Change to Bar </br>";
$driver = new driver($input);
?>
Run Code Online (Sandbox Code Playgroud) php class global-variables objectinstantiation getter-setter