最近很多小伙伴都在问css–为什么我的转换会重新开始?和css转换器这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展c#–为什么我的转换器会出现无效的转换错误?、css–320及以
最近很多小伙伴都在问css – 为什么我的转换会重新开始?和css转换器这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展c# – 为什么我的转换器会出现无效的转换错误?、css – 320及以上的移动框架 – 为什么样式表从480开始?、css – 为什么我的div不会扩展到内容的大小、css – 为什么我的Google Web字体像素化?等相关知识,下面开始了哦!
本文目录一览:- css – 为什么我的转换会重新开始?(css转换器)
- c# – 为什么我的转换器会出现无效的转换错误?
- css – 320及以上的移动框架 – 为什么样式表从480开始?
- css – 为什么我的div不会扩展到内容的大小
- css – 为什么我的Google Web字体像素化?
css – 为什么我的转换会重新开始?(css转换器)
.blockquote { font-family: "Open Sans",Verdana,Arial,sans-serif; font-size: 30px; line-height: 60px; width: 100%; background-color: rgba(0,0.16); /*rgba(192,241,247,0.15);*/ height: 100px; text-align: center; padding-top: 40px; color: white; font-weight: 300; font-style: italic; transition: all 250ms ease-in-out; } .blockquote .blockquote2 { transition: all 250ms ease-in-out; font-size: 25px; line-height: 35px; width: 90%; } .blockquote .author { display: inline; margin-left: -150px; transition: all 250ms ease-in-out; font-family: "Roboto",sans-serif; color: #838eca; text-transform: uppercase; font-size: 20px; letter-spacing: 2px; line-height: 35px; opacity: 0; } .blockquote:hover .blockquote2 { transform: translateX(-20px); transition: all 250ms ease-in-out; } .blockquote:hover .author { opacity: 1; font-weight: 900; color: rgb(25,137,228); transform: translateX(200px); transition: all 250ms ease-in-out; }
<div> <div> <b>雕刻</b>自己的路 <p>- Jason Zhang</p> </div> </div>
解决方法
CSS变换通常不能应用于具有显示的元素:内联设置.虽然奇怪的是转换似乎最初在抢回之前发生,但解决方案是将设置更改为显示:内联块,如下面的代码段所示.
.blockquote { font-family: "Open Sans",0.15);*/ height: 100px; text-align: center; padding-top: 40px; color: white; font-weight: 300; font-style: italic; transition: all 250ms ease-in-out; } .blockquote .blockquote2 { transition: all 250ms ease-in-out; font-size: 25px; line-height: 35px; width: 90%; } .blockquote .author { display: inline-block; margin-left: -150px; transition: all 250ms ease-in-out; font-family: "Roboto",228); transform: translateX(200px); transition: all 250ms ease-in-out; }
<div> <div> <b>雕刻</b>自己的路 <p>- Jason Zhang</p> </div> </div>
如果元素不可转换,为什么元素最初会被翻译?
浏览器(至少Chrome)的行为似乎很奇怪,我只能认为这是一个错误,但很可能这种行为是由于浏览器中的加速渲染以及创建和移动图层以提供更高性能的方式.
在现代浏览器中,只要某个条件与渲染对象(DOM节点)匹配并且具有动画/转换变换就是其中之一,就会创建合成图层(请参阅参考文献中提到的文章).现在,当发生这种情况时,GPU通过更改其合成属性将转换仅应用于合成层.这(由于某些原因我不知道)似乎没有考虑元素的显示设置,因此元素/层被翻译.
然而,在转换的开始和结束时,浏览器重新绘制整个页面,因为一旦转换完成就不需要额外的合成层,并且此重新绘制似乎将元素放回原始位置.
下面是一个非常简单的代码片段,我使用span标签上的变换创建,以说明我的观点.从Chrome开发工具启用“显示绘制矩形”和“显示合成图层边框”选项后运行代码段(请参阅参考项3以了解如何启用这些设置).您将注意到,最初当您将鼠标悬停在身体上的任何位置并且即将开始转换时,会发生绘制(屏幕上出现绿色或红色闪烁)以创建合成图层.完成此过程后,您会注意到橙色边框已应用于span标记.这是合成图层,您将看到当转换发生时,此图层如何移动.最后,另一次重新绘制会删除图层(因为不再需要),这会根据规格将元素放回正确的位置.
body:hover span { transition: all 1s 1s; transform: translateX(200px); }
<span>abcd</span>
如前所述,我无法提供关于合成层为何如此行为的权威答案,但基于示例代码段和参考文章,您可以看到我的断言保持良好.
参考文献:
> W3C Spec – Transformable elements
> Chromium Projects – GPU Accelerated Rendering in Chrome
> HTML5 Rocks – Accelerated Rendering in Chrome
c# – 为什么我的转换器会出现无效的转换错误?
但是行“return(int)value;”总是得到“指定演员阵容无效”.
我该怎么做才能让我的Converter成功转换一个double并发回一个整数?
转换器:
namespace TestChangeAngle { [ValueConversion(typeof(double),typeof(int))] class DoubletoIntegerConverter : IValueConverter { #region IValueConverter Members public object Convert(object value,Type targettype,object parameter,System.Globalization.CultureInfo culture) { return (int)value; } public object ConvertBack(object value,System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } #endregion } }
XAML:
<Page x:xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:TestChangeAngle" Title="Page1"> <Page.Resources> <local:DoubletoIntegerConverter x:Key="DoubletoIntegerConverter"/> </Page.Resources> <StackPanel HorizontalAlignment="Left" Margin="20"> <Image Source="images\logo2.png" RenderTransformOrigin="0.5,0.5" Width="100" Margin="10"> <Image.RenderTransform> <RotateTransform Angle="{Binding ElementName=TheSlider,Path=Value}"/> </Image.RenderTransform> </Image> <Slider x:Name="TheSlider" Width="200" Minimum="0" Maximum="360" HorizontalAlignment="Center" Margin="10" Cursor="Hand"/> <TextBox x:Name="TheAngle" Margin="10" Width="100"> <TextBox.Text> <Binding ElementName="TheSlider" Path="Value" UpdateSourceTrigger="PropertyChanged" Converter="{StaticResource DoubletoIntegerConverter}" Mode="TwoWay"> <Binding.ValidationRules> <local:MinMaxValidationRule Minimum="0" Maximum="360"/> </Binding.ValidationRules> </Binding> </TextBox.Text> </TextBox> </StackPanel> </Page>
解决方法
public object Convert(object value,System.Globalization.CultureInfo culture) { return Convert.ToInt32(value); }
当对象具有相同的形状时,即当一个对象是您要转换的类型的实例时,可以使用强制转换操作符.例如,如果类Foo扩展了类Bar,那么您可以将类型为Foo的对象转换为类型Bar – 因为Foo对象具有Bar对象所具有的所有方法和属性.但是,您无法将类型为Bar的对象强制转换为Foo,因为通过添加Bar对象不具有的方法或属性,Foo会更改(或者可以更改,就编译器而言)Bar的形状.
在你的情况下,你正在处理只共享对象接口的原始类型 – 除了它们都是从对象派生之外,它们之间没有继承关系.然而,两者之间存在隐含的转换.您可以将一种类型的对象分配给另一种类型的变量,但可能会丢失该值的某些精度.
double x = 1.1; int y = 0; y = x; // implicit conversion,this works,y will be 1 x = y; // implicit conversion,x will be 1.0
但是,您不能将一种类型的对象强制转换为另一种对象.强制转换意味着您将使用该对象,就好像它是另一种类型一样.在这种情况下,形状不同,无法完成.
css – 320及以上的移动框架 – 为什么样式表从480开始?
> 480.css
> 600.css
> 768.css
> 992.css
> 1382.css
和print.css,style.css和2x.css
我不明白为什么不是320.css样式表,或者我应该使用style.css作为该分辨率?
解决方法
<!-- For all browsers --> <link rel="stylesheet" href="css/style.css"> <link rel="stylesheet" media="print" href="css/print.css"> <!-- For progressively larger displays --> <link rel="stylesheet" media="only screen and (min-width: 480px)" href="css/480.css"> <link rel="stylesheet" media="only screen and (min-width: 600px)" href="css/600.css"> <link rel="stylesheet" media="only screen and (min-width: 768px)" href="css/768.css"> <link rel="stylesheet" media="only screen and (min-width: 992px)" href="css/992.css">
因此,对于器件宽度,0 – 480px(包括320px)的设计将采用style.css
480至600 = 480.css
600至768 = 600.css
768至992 = 768.css
992 = 992.css
但是如果你想在320分辨率上有更多细粒度控制,你可以添加另一个媒体查询:
< link rel =“stylesheet”media =“only screen and(min-width:320px)”href =“css / 320.css”>
然后在css目录中创建320.css样式表.这张表适用于分辨率320 – 480.这意味着现在小于320的任何内容都将加载style.css.
我认为将该解决方案排除在外的想法是,您可以创建一些流畅或灵活的布局,这对两种分辨率都有效…
css – 为什么我的div不会扩展到内容的大小
我的example显示了当最右边的列(#rightBox)有太多信息并且它突破主包装器(#interior_wrap)时会发生什么.
因为#rightBox是浮动的,我确信这是导致它的原因,但我认为我太接近了解决方案,所以任何帮助都会很棒.
提前致谢!
解决方法
#container { overflow:hidden; zoom:1; }
或#container:after {content:“”;明确:两者;显示:块;如果你得到削减.
PS – 不要使用position:absolute来居中,使用margin:0 auto
css – 为什么我的Google Web字体像素化?
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css' >
css是
body { padding: 0; text-align: center; line-height: 180%; background: #1a2426; color: #f7f7f7; font-family: 'Lobster',serif; }
问题是当我将其拉入Chrome时,字体看起来像素化.我想知道有没有人可以解释为什么?
例
解决方法
检查这个https://graphicdesign.stackexchange.com/questions/265/font-face-loaded-on-windows-look-really-bad-which-font-are-you-using-that-are
关于css – 为什么我的转换会重新开始?和css转换器的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于c# – 为什么我的转换器会出现无效的转换错误?、css – 320及以上的移动框架 – 为什么样式表从480开始?、css – 为什么我的div不会扩展到内容的大小、css – 为什么我的Google Web字体像素化?等相关知识的信息别忘了在本站进行查找喔。
本文标签: