我目前正在构建一个网站,要求按钮在按钮的左侧倾斜。该网站响应迅速,按钮也需要圆 Angular 。我也尽量避免使用背景图片。
有人能告诉我一个解决方案吗?忽略按钮上的图标,我可以做到这一点。我只需要倾斜的一面。
body {
background: lightblue;
font-family: sans-serif;
}
div {
background: purple;
width: 200px;
padding: 30px;
border: 3px solid white;
color: white;
}<div>Some Text</div>
最佳答案
Note: I am adding a separate answer because though the answers that I linked in comment seem to give a solution, this one is a bit more complex due to the presence of border also along with the border-radius.
可以使用以下部分创建形状:
我还在代码片段中添加了一个悬停效果来展示形状的响应特性。
.outer {
position: relative;
height: 75px;
width: 300px;
text-align: center;
line-height: 75px;
color: white;
text-transform: uppercase;
}
.outer:before,
.outer:after {
position: absolute;
content: '';
top: 0px;
height: 100%;
width: 55%;
background: purple;
border: 2px solid white;
border-left-width: 3px;
z-index: -1;
}
.outer:before {
left: 0px;
border-radius: 20px;
border-right: none;
transform: skew(20deg);
transform-origin: top left;
}
.outer:after {
right: 0px;
border-top-right-radius: 20px;
border-bottom-right-radius: 20px;
border-left: none;
}
/* Just for demo of responsive nature */
.outer{
transition: all 1s;
}
.outer:hover{
height: 100px;
width: 400px;
line-height: 100px;
}
body{
background: lightblue;
}<div class='outer'>
Call me back
</div>
优点:
在下面的代码片段中,我为每个组件赋予了不同的颜色以直观地说明形状是如何实现的:
.outer {
position: relative;
height: 75px;
width: 300px;
text-align: center;
line-height: 75px;
color: white;
text-transform: uppercase;
}
.outer:before,
.outer:after {
position: absolute;
content: '';
top: 0px;
height: 100%;
width: 55%;
background: purple;
border: 2px solid white;
border-left-width: 3px;
z-index: -1;
}
.outer:before {
left: 0px;
border-radius: 20px;
border-right: none;
transform: skew(20deg);
transform-origin: top left;
background: seagreen;
border-color: red;
}
.outer:after {
right: 0px;
border-top-right-radius: 20px;
border-bottom-right-radius: 20px;
border-left: none;
background: yellowgreen;
border-color: maroon;
}
/* Just for demo of responsive nature */
.outer{
transition: all 1s;
}
.outer:hover{
height: 100px;
width: 400px;
line-height: 100px;
}
body{
background: lightblue;
}<div class='outer'>
Call me back
</div>
关于html - 带有斜边和圆 Angular 的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32045637/
我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h
在我的Controller中,我通过以下方式在我的index方法中支持HTML和JSON:respond_todo|format|format.htmlformat.json{renderjson:@user}end在浏览器中拉起它时,它会自然地以HTML呈现。但是,当我对/user资源进行内容类型为application/json的curl调用时(因为它是索引方法),我仍然将HTML作为响应。如何获取JSON作为响应?我还需要说明什么? 最佳答案 您应该将.json附加到请求的url,提供的格式在routes.rb的路径中定义。这
所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择
我使用Nokogiri(Rubygem)css搜索寻找某些在我的html里面。看起来Nokogiri的css搜索不喜欢正则表达式。我想切换到Nokogiri的xpath搜索,因为这似乎支持搜索字符串中的正则表达式。如何在xpath搜索中实现下面提到的(伪)css搜索?require'rubygems'require'nokogiri'value=Nokogiri::HTML.parse(ABBlaCD3"HTML_END#my_blockisgivenmy_bl="1"#my_eqcorrespondstothisregexmy_eq="\/[0-9]+\/"#FIXMEThefoll
我正在使用Rails构建一个简单的聊天应用程序。当用户输入url时,我希望将其输出为html链接(即“url”)。我想知道在Ruby中是否有任何库或众所周知的方法可以做到这一点。如果没有,我有一些不错的正则表达式示例代码可以使用... 最佳答案 查看auto_linkRails提供的辅助方法。这会将所有URL和电子邮件地址变成可点击的链接(htmlanchor标记)。这是文档中的代码示例。auto_link("Gotohttp://www.rubyonrails.organdsayhellotodavid@loudthinking.
我正在学习http://ruby.railstutorial.org/chapters/static-pages上的RubyonRails教程并遇到以下错误StaticPagesHomepageshouldhavethecontent'SampleApp'Failure/Error:page.shouldhave_content('SampleApp')Capybara::ElementNotFound:Unabletofindxpath"/html"#(eval):2:in`text'#./spec/requests/static_pages_spec.rb:7:in`(root)'
我正在尝试将一个简单的CSV文件读入HTML表格以在浏览器中显示,但我遇到了麻烦。这就是我正在尝试的:Controller:defshow@csv=CSV.open("file.csv",:headers=>true)end查看:输出:NameStartDateEndDateQuantityPostalCode基本上我只获取标题,而不会读取和呈现CSV正文。 最佳答案 这最终成为最终解决方案:Controller:defshow#OpenaCSVfile,andthenreaditintoaCSV::Tableobjectforda
使用rspec-rails3.0+,测试设置分为spec_helper和rails_helper我注意到生成的spec_helper不需要'rspec/rails'。这会导致zeus崩溃:spec_helper.rb:5:in`':undefinedmethod`configure'forRSpec:Module(NoMethodError)对thisissue最常见的回应是需要'rspec/rails'。但这是否会破坏仅使用spec_helper拆分rails规范和PORO规范的全部目的?或者这无关紧要,因为Zeus无论如何都会预加载Rails?我应该在我的spec_helper中做
我有一个使用SeleniumWebdriver和Nokogiri的Ruby应用程序。我想选择一个类,然后对于那个类对应的每个div,我想根据div的内容执行一个Action。例如,我正在解析以下页面:https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=puppies这是一个搜索结果页面,我正在寻找描述中包含“Adoption”一词的第一个结果。因此机器人应该寻找带有className:"result"的div,对于每个检查它的.descriptiondiv是否包含单词“adoption
假设我有一个类A,里面有一些方法。假设stringmethodName是这些方法之一,我已经知道我想给它什么参数。它们在散列中{'param1'=>value1,'param2'=>value2}所以我有:params={'param1'=>value1,'param2'=>value2}a=A.new()a.send(methodName,value1,value2)#callmethodnamewithbothparams我希望能够通过传递我的哈希以某种方式调用该方法。这可能吗? 最佳答案 确保methodName是一个符号,而