[英]make a custom shaped div css html
I am trying to make a div with the following shape but with no success .Here is what i have done Fiddle 我正在尝试使div具有以下形状但没有成功。这是我所做的Fiddle
Here is the code so far. 这是到目前为止的代码。
.skew {
display: inline-block;
background-color:black;
height: 120px;
width: 360px;
margin-top: 100px;
-webkit-transform: skewY(-11deg);
-moz-transform: skewY(-11deg);
-ms-transform: skewY(-11deg);
-o-transform: skewY(-11deg);
transform: skewY(-11deg);
overflow:hidden;
}
Any solution is welcomed 欢迎任何解决方案
A basic untested approach (if I understood your idea correctly): 一种未经测试的基本方法(如果我正确理解了您的想法):
HTML: HTML:
<div class="skew-container">
<div class="img-container"></div>
</div>
CSS: CSS:
.skew-container { overflow: hidden; background: url(/images/skew.png) no-repeat scroll 0 0 transparent; height: 175px; width: 484px; }
.img-container { height: 100%; width: 100%; }
.img-container img { width: 100%; }
JS: JS:
Now for JavaScript, there's a lot you can do. 现在,对于JavaScript,您可以做很多事情。 But I'm not sure if you'd like to move one of the two images around. 但是我不确定您是否要移动两个图像之一。 Take a look at my little dice game. 看看我的小骰子游戏。 How far down the rabbit hole are you willing to go? 您愿意走多远的兔子洞? http://jsfiddle.net/tive/GcDAb/ http://jsfiddle.net/tive/GcDAb/
The approach shown in the example is a large image with all the dice values and colors. 示例中显示的方法是一张具有所有骰子值和颜色的大图像。 Moving the image is mathematical, like a matrix, using background-position
to CSS. 使用CSS的background-position
来移动图像是数学的,就像矩阵一样。 A little browser inconsistent but still doable. 一点浏览器不一致但仍然可行。
you need to use 3D & perspective in your test : 您需要在测试中使用3D和透视图:
body {
transform-style: preserve-3d;
perspective:50px;
}
with help from a pseudo, you can do something like this : http://jsfiddle.net/FCVa7/3/ 在伪人员的帮助下,您可以执行以下操作: http : //jsfiddle.net/FCVa7/3/
Needs to be tuned to your needs .... 需要根据您的需求进行调整....
but best is look at SVG to make your shapes and then you can style them from style sheet 但最好的方法是查看SVG制作形状,然后可以从样式表中对其进行样式设置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.