关闭。这个问题需要更多focused .它目前不接受答案。
想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post .
7年前关闭。
Improve this question
1. 目标
我正在研究一种高度动态、可扩展的块/内联块级元素样式。它看起来像这样:

2. 我真正需要的
从我的选项中进行选择的建议,基本上。什么方法与作为主要关注点的跨浏览器友好性和可扩展性最兼容?
我使用 SASS 来渲染我的 CSS,所以 <style>我的示例中的元素是伪代码。我希望能够使用明确定义的类层次结构动态控制以下内容:
<!-- the HTML -->
<div class="arrow-label">
<h4 class="expand"><?php echo $label-text;?></h4>
<a href="#" class="triangle right-facing"></a>
</div>
<style>
div.arrow-label {
h4 {
display:inline-block;
background-color: $arrow-label-background-color;
}
.triangle { background-color: $arrow-label-background-color; }
}
.triangle {
width:0;
height:0;
display:inline-block;
margin:0;
border-style: solid;
transition: border-color 300ms ease-out;
// I have removed transitional selectors (ie. :hover) below for brevity's sake
&.up-facing {
border-width: 0 rem-calc(12px) rem-calc(15px) rem-calc(12px);
border-color: transparent transparent $triangle-color transparent;
}
// rinse/repeat for .left-facing, .right-facing, .bottom-facing
&.disabled {
transition:none;
color: $triangle-disabled-color;
}
&.inherited-transition { transition: inherit}
}
</style>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="635.436px" height="156.041px" viewBox="0 0 635.436 156.041" enable-background="new 0 0 635.436 156.041"
xml:space="preserve">
<polygon fill="#333333" points="576.576,155.254 635.436,78.02 576.576,0.787 576.576,0 575.976,0 575.976,0 575.976,0 0,0
0,156.041 576.576,156.041 "/>
</svg>
background-image,我将无法实现目标。否则包含文本的元素的属性参数;但我也不知道这是如何通过 CSS 即时完成的。/* The element itself */
div.arrow-label h4 {
display: inline-block;
background-color: #323232;
}
/* the code I use to make triangles, and in this case, would be capping the element with
note that, as per the standard, 1rem = 16px here */
.triangle {
width: 0;
height: 0;
display: inline-block;
margin: 0;
border-style: solid;
transition: border-color 300ms ease-out;
}
.triangle.up-facing {
border-width: 0 0.75rem 0.9375rem 0.75rem;
border-color: transparent transparent #ff5555 transparent;
}
.triangle.up-facing:hover {
border-color: transparent transparent #ffa1a1 transparent;
}
.triangle.up-facing:active {
border-color: transparent transparent #683939 transparent;
}
.triangle.down-facing {
border-width: 0.9375rem 0.75rem 0 0.75rem;
border-color: #ff5555 transparent transparent transparent;
}
.triangle.down-facing:hover {
border-color: #ffa1a1 transparent transparent transparent;
}
.triangle.down-facing:active {
border-color: #bb0000 transparent transparent transparent;
}
.triangle.right-facing {
border-width: 0.75rem 0 0.75rem 0.9375rem;
border-color: transparent transparent transparent #ff5555;
}
.triangle.right-facing:hover {
border-color: transparent transparent transparent #ffa1a1;
}
.triangle.right-facing:active {
border-color: transparent transparent transparent #683939;
}
.triangle.left-facing {
border-width: 0.75rem 0.9375rem 0.75rem 0;
border-color: transparent #ff5555 transparent transparent;
}
.triangle.left-facing:hover {
border-color: transparent #ffa1a1 transparent transparent;
}
.triangle.left-facing:active {
border-color: transparent #683939 transparent transparent;
}
.triangle.disabled {
transition: none;
color: #ffa1a1;
}
.triangle.inherited-transition {
transition: inherit;
}
最佳答案
SVG 文件(简化代码)
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 100" >
<polygon fill="#333" points="0,0 460,0 500,50 460,100 0,100" />
</svg>
<style>#my_block{
width: 190px;
height: 40px;
background-image: url(../images/arrow.svg);/*change to the svg url*/
background-position: right center;
background-size: auto 100%;
transition: 100ms 200ms ease-out;
}
#my_block:hover{
width: 200px;
transition: 100ms ease-out;
opacity: 0.7;
}
<div id="my_block"></div>
关于css - 在纯 CSS、CSS/SVG 或 CSS/HTML5 中构建动态和可重用图形元素的最跨浏览器安全方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24536396/
我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h
我在MiniTest::Spec和Capybara中使用以下规范:find_field('Email').must_have_css('[autofocus]')检查名为“电子邮件”的字段是否具有autofocus属性。doc说如下:has_css?(path,options={})ChecksifagivenCSSselectorisonthepageorcurrentnode.据我了解,字段“Email”是一个节点,因此调用must_have_css绝对有效!我做错了什么? 最佳答案 通过JonasNicklas得到了答案:No
在我的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并在看到包时选择
我正在尝试在Ruby中制作一个cli应用程序,它接受一个给定的数组,然后将其显示为一个列表,我可以使用箭头键浏览它。我觉得我已经在Ruby中看到一个库已经这样做了,但我记不起它的名字了。我正在尝试对soundcloud2000中的代码进行逆向工程做类似的事情,但他的代码与SoundcloudAPI的使用紧密耦合。我知道cursesgem,我正在考虑更抽象的东西。广告有没有人见过可以做到这一点的库或一些概念证明的Ruby代码可以做到这一点? 最佳答案 我不知道这是否是您正在寻找的,但也许您可以使用我的想法。由于我没有关于您要完成的工作
我的主要目标是能够完全理解我正在使用的库/gem。我尝试在Github上从头到尾阅读源代码,但这真的很难。我认为更有趣、更温和的踏脚石就是在使用时阅读每个库/gem方法的源代码。例如,我想知道RubyonRails中的redirect_to方法是如何工作的:如何查找redirect_to方法的源代码?我知道在pry中我可以执行类似show-methodmethod的操作,但我如何才能对Rails框架中的方法执行此操作?您对我如何更好地理解Gem及其API有什么建议吗?仅仅阅读源代码似乎真的很难,尤其是对于框架。谢谢! 最佳答案 Ru
我正在使用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)'
我有一个div,它根据表单是否正确提交而改变。我想知道是否可以检查类的特定元素?开始元素看起来像这样。如果输入不正确,添加错误类。 最佳答案 试试这个:browser.div(:id=>"myerrortest").class_name更多信息:http://watir.github.com/watir-webdriver/doc/Watir/HTMLElement.html#class_name-instance_method另一种选择是只查看具有您期望的类的div是否存在browser.div((:id=>"myerrortes
我正在尝试将一个简单的CSV文件读入HTML表格以在浏览器中显示,但我遇到了麻烦。这就是我正在尝试的:Controller:defshow@csv=CSV.open("file.csv",:headers=>true)end查看:输出:NameStartDateEndDateQuantityPostalCode基本上我只获取标题,而不会读取和呈现CSV正文。 最佳答案 这最终成为最终解决方案:Controller:defshow#OpenaCSVfile,andthenreaditintoaCSV::Tableobjectforda