.circle {
width: 40px;
height: 40px;
border-radius: 50%;
background-color: yellow;
position: absolute;
z-index: 20;
border: 1px solid #AAAAAA;
box-shadow: 0 0 8px 2px yellow;
}
.roof {
width: 280px;
height: 80px;
background-color: gray;
border-top-left-radius: 50%;
border-top-right-radius: 50%;
left: 0;
z-index: -2;
position: relative;
}
.windscreen {
width: 260px;
height: 75px;
background: rgb(41, 137, 216);
/* Old browsers */
background: -moz-linear-gradient(-45deg, rgba(41, 137, 216, 1) 10%, rgba(170, 170, 170, 1) 22%, rgba(41, 137, 216, 1) 35%, rgba(170, 170, 170, 1) 50%, rgba(41, 137, 216, 1) 65%, rgba(170, 170, 170, 1) 78%, rgba(41, 137, 216, 1) 90%, rgba(41, 137, 216, 1) 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, right bottom, color-stop(10%, rgba(41, 137, 216, 1)), color-stop(22%, rgba(170, 170, 170, 1)), color-stop(35%, rgba(41, 137, 216, 1)), color-stop(50%, rgba(170, 170, 170, 1)), color-stop(65%, rgba(41, 137, 216, 1)), color-stop(78%, rgba(170, 170, 170, 1)), color-stop(90%, rgba(41, 137, 216, 1)), color-stop(100%, rgba(41, 137, 216, 1)));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(-45deg, rgba(41, 137, 216, 1) 10%, rgba(170, 170, 170, 1) 22%, rgba(41, 137, 216, 1) 35%, rgba(170, 170, 170, 1) 50%, rgba(41, 137, 216, 1) 65%, rgba(170, 170, 170, 1) 78%, rgba(41, 137, 216, 1) 90%, rgba(41, 137, 216, 1) 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(-45deg, rgba(41, 137, 216, 1) 10%, rgba(170, 170, 170, 1) 22%, rgba(41, 137, 216, 1) 35%, rgba(170, 170, 170, 1) 50%, rgba(41, 137, 216, 1) 65%, rgba(170, 170, 170, 1) 78%, rgba(41, 137, 216, 1) 90%, rgba(41, 137, 216, 1) 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(-45deg, rgba(41, 137, 216, 1) 10%, rgba(170, 170, 170, 1) 22%, rgba(41, 137, 216, 1) 35%, rgba(170, 170, 170, 1) 50%, rgba(41, 137, 216, 1) 65%, rgba(170, 170, 170, 1) 78%, rgba(41, 137, 216, 1) 90%, rgba(41, 137, 216, 1) 100%);
/* IE10+ */
background: linear-gradient(135deg, rgba(41, 137, 216, 1) 10%, rgba(170, 170, 170, 1) 22%, rgba(41, 137, 216, 1) 35%, rgba(170, 170, 170, 1) 50%, rgba(41, 137, 216, 1) 65%, rgba(170, 170, 170, 1) 78%, rgba(41, 137, 216, 1) 90%, rgba(41, 137, 216, 1) 100%);
/* W3C */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#2989d8', endColorstr='#2989d8', GradientType=1);
/* IE6-9 fallback on horizontal gradient */
margin-left: 10px;
box-shadow: inset 0 0 0 2px #000;
/*not sure of this*/
}
.roof-bonnet {
height: 320px;
margin-top: -100px;
}
#numberplate {
height: 40px;
width: 190px;
background-color: white;
bottom: 10px;
position: relative;
margin-top: -45px;
margin-left: 44px;
border: 2px solid black;
font-size: auto;
text-align: center;
}
.circle-headlight {
margin-top: -55px;
background-color: white;
box-shadow: 0 0 8px 2px white;
}
.right-headlight {
margin-left: 238px;
}<div class="circle"></div>
<div class="circle" style="margin-left:240px;"></div>
<div class="roof"></div>
<div class="windscreen"></div>
<div class="roof roof-bonnet"></div>
<div class="circle circle-headlight"></div>
<div class="circle circle-headlight right-headlight"></div>
<div id="numberplate">REG PLATE</div>
我一直在尝试在 CSS 中生成一辆卡车,但在生成后视镜时遇到了一些困难,我认为这主要是因为我对 position 的设计/使用不当。
我目前有上面的代码,它生成了基本的卡车形状(无论如何都不完整)。
我想添加如下内容:
+-------+
| | \
| | |
| /| |
| //| |
| // | |
| // /| |
| // //| |
| // // |_________/
--- +//
-----+
|
|
任一侧。
对于在不“破坏”当前笔的情况下添加这个,有人有什么建议吗?
到目前为止,我已尝试使用以下方法生成此形状:
#wing-mirror {
margin-top:40px;
width: 100px;
height: 50px;
background: red;
position: relative;
transform: rotate(-90deg);
border-radius:20px;
}
#wing-mirror:after {
content: "";
position: absolute;
bottom: 0;
left: 0;
border-top: 10px solid red;
border-left: 29px solid #fff;
border-right: 29px solid #fff;
width: 42px;
height: 0;
}
我已经创建了这个“后视镜”,但是由于我使用了特定的值,将这个“下一个”放在我的卡车上,对齐中断了,所以无论我在哪里,“引擎盖/挡风玻璃/车顶”都没有正确对齐将这个后视镜放在我的 html 中。
我完成的后视镜是这样的:
#wing-mirror {
margin-top: 40px;
width: 100px;
height: 50px;
background: gray;
position: relative;
transform: rotate(-90deg);
border-radius: 20px;
}
#wing-mirror:after {
content: "";
position: absolute;
bottom: 0;
left: 0;
border-top: 10px solid gray;
border-left: 29px solid #fff;
border-right: 29px solid #fff;
width: 42px;
height: 0;
}
.border-div {
width: 75px;
background-color: gray;
height: 10px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
margin-left: 30px;
}
.border-div-top {
width: 50px;
background-color: gray;
height: 10px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
margin-left: 50px;
margin-top: -20px;
}<div id="wing-mirror"></div>
<div class="border-div"></div>
<div class="border-div-top"></div>
但是我怎样才能把它安装到我的整辆卡车上呢?因为我尝试过的一切都会导致“跳跃”元素(它们不会“粘”在卡车上)并且它们不会正确对齐到元素的侧面(不会出现在卡车的左侧或右侧,可能是由于实现不当)。
最佳答案
Disclaimer: I don't believe this approach is the best to create the shape you are after. Depending on your use case, you should look into SVG or a normal png/jpeg.
我为每个镜子添加了一个元素,并在 .windscreen div 上为镜子臂使用了带有边框的倾斜伪元素。
为了定位镜子,我将 position:relative; 添加到 .windscreen div 并将镜子作为该 div 的子元素插入。这样就可以使用绝对定位将后视镜相对于挡风玻璃左右放置。
body{
padding-left:100px;
}
.circle {
width: 40px;
height: 40px;
border-radius: 50%;
background-color: yellow;
position: absolute;
z-index: 20;
border: 1px solid #AAAAAA;
box-shadow: 0 0 8px 2px yellow;
}
.roof {
width: 280px;
height: 80px;
background-color: gray;
border-top-left-radius: 50%;
border-top-right-radius: 50%;
left: 0;
z-index: -2;
position: relative;
}
.windscreen {
position:relative;
width: 260px;
height: 75px;
background: rgb(41, 137, 216);
/* Old browsers */
background: -moz-linear-gradient(-45deg, rgba(41, 137, 216, 1) 10%, rgba(170, 170, 170, 1) 22%, rgba(41, 137, 216, 1) 35%, rgba(170, 170, 170, 1) 50%, rgba(41, 137, 216, 1) 65%, rgba(170, 170, 170, 1) 78%, rgba(41, 137, 216, 1) 90%, rgba(41, 137, 216, 1) 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, right bottom, color-stop(10%, rgba(41, 137, 216, 1)), color-stop(22%, rgba(170, 170, 170, 1)), color-stop(35%, rgba(41, 137, 216, 1)), color-stop(50%, rgba(170, 170, 170, 1)), color-stop(65%, rgba(41, 137, 216, 1)), color-stop(78%, rgba(170, 170, 170, 1)), color-stop(90%, rgba(41, 137, 216, 1)), color-stop(100%, rgba(41, 137, 216, 1)));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(-45deg, rgba(41, 137, 216, 1) 10%, rgba(170, 170, 170, 1) 22%, rgba(41, 137, 216, 1) 35%, rgba(170, 170, 170, 1) 50%, rgba(41, 137, 216, 1) 65%, rgba(170, 170, 170, 1) 78%, rgba(41, 137, 216, 1) 90%, rgba(41, 137, 216, 1) 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(-45deg, rgba(41, 137, 216, 1) 10%, rgba(170, 170, 170, 1) 22%, rgba(41, 137, 216, 1) 35%, rgba(170, 170, 170, 1) 50%, rgba(41, 137, 216, 1) 65%, rgba(170, 170, 170, 1) 78%, rgba(41, 137, 216, 1) 90%, rgba(41, 137, 216, 1) 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(-45deg, rgba(41, 137, 216, 1) 10%, rgba(170, 170, 170, 1) 22%, rgba(41, 137, 216, 1) 35%, rgba(170, 170, 170, 1) 50%, rgba(41, 137, 216, 1) 65%, rgba(170, 170, 170, 1) 78%, rgba(41, 137, 216, 1) 90%, rgba(41, 137, 216, 1) 100%);
/* IE10+ */
background: linear-gradient(135deg, rgba(41, 137, 216, 1) 10%, rgba(170, 170, 170, 1) 22%, rgba(41, 137, 216, 1) 35%, rgba(170, 170, 170, 1) 50%, rgba(41, 137, 216, 1) 65%, rgba(170, 170, 170, 1) 78%, rgba(41, 137, 216, 1) 90%, rgba(41, 137, 216, 1) 100%);
/* W3C */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#2989d8', endColorstr='#2989d8', GradientType=1);
/* IE6-9 fallback on horizontal gradient */
margin-left: 10px;
box-shadow: inset 0 0 0 2px #000;
/*not sure of this*/
}
.roof-bonnet {
height: 320px;
margin-top: -100px;
}
#numberplate {
height: 40px;
width: 190px;
background-color: white;
bottom: 10px;
position: relative;
margin-top: -45px;
margin-left: 44px;
border: 2px solid black;
font-size: auto;
text-align: center;
}
.circle-headlight {
margin-top: -55px;
background-color: white;
box-shadow: 0 0 8px 2px white;
}
.right-headlight {
margin-left: 238px;
}
.windscreen:after{
content:'';
position:absolute;
left:100%; bottom:15px;
width:10px; height:20px;
transform:skewX(-30deg);
border-bottom:12px solid #000;
border-right: 12px solid #000;
z-index:-1;
}
.windscreen:before{
content:'';
position:absolute;
right:100%; bottom:15px;
width:10px; height:20px;
transform:skewX(30deg);
border-bottom:12px solid #000;
border-left: 12px solid #000;
z-index:-1;
}
.mirror{
position:absolute;
left:100%; top:20px;
margin-left:19px;
height: 30px;
width:20px;
background:#000;
}
.mirror:before, .mirror:after{
content:'';
position:absolute;
width:100%;
box-sizing:border-box;
bottom:100%;
border-color: #000 transparent;
border-width: 0 5px 10px 0;
border-style:solid;
}
.mirror:after{
bottom:auto;
top:100%;
border-width: 7px 3px 0 0;
}
.mirrorL{
position:absolute;
right:100%; top:20px;
margin-right:19px;
height: 30px;
width:20px;
background:#000;
}
.mirrorL:before, .mirrorL:after{
content:'';
position:absolute;
width:100%;
box-sizing:border-box;
bottom:100%;
border-color: #000 transparent;
border-width: 0 0 10px 5px;
border-style:solid;
}
.mirrorL:after{
bottom:auto;
top:100%;
border-width: 7px 0 0 3px;
}<div class="circle"></div>
<div class="circle" style="margin-left:240px;"></div>
<div class="roof"></div>
<div class="windscreen"><div class="mirror"></div><div class="mirrorL"></div></div>
<div class="roof roof-bonnet"></div>
<div class="circle circle-headlight"></div>
<div class="circle circle-headlight right-headlight"></div>
<div id="numberplate">REG PLATE</div>
关于html - 如何创建卡车/卡车后视镜的形状?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27355331/
我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div
总的来说,我对ruby还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用
出于纯粹的兴趣,我很好奇如何按顺序创建PI,而不是在过程结果之后生成数字,而是让数字在过程本身生成时显示。如果是这种情况,那么数字可以自行产生,我可以对以前看到的数字实现垃圾收集,从而创建一个无限系列。结果只是在Pi系列之后每秒生成一个数字。这是我通过互联网筛选的结果:这是流行的计算机友好算法,类机器算法:defarccot(x,unity)xpow=unity/xn=1sign=1sum=0loopdoterm=xpow/nbreakifterm==0sum+=sign*(xpow/n)xpow/=x*xn+=2sign=-signendsumenddefcalc_pi(digits
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack
使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta