草庐IT

html - 带 Angular 边框的 IMG 尺寸

coder 2023-08-11 原文

我想将 2 个 img 用斜 Angular 边框分开。我第一次设法调整大小。我尝试了第二个,但到目前为止对我没有任何帮助。 到目前为止我的工作: 即使我尝试单独制作,第二个 img 也没有得到倾斜的边框 背景看起来像这样,我希望图像与 Angular 相匹配。

.left,
.right {
  background: #000;
  position: relative;
  height: 100px;
  width: 45%;
  float: left;
  margin-top: 10px;
  opacity: 10%;
}

.right,
.right img {
  margin-left: 0px;
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
}

.left,
.left img {
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
}

.left:after {
  content: '';
  line-height: 0;
  font-size: 0;
  width: 0;
  height: 0;
  border-top: 50px solid transparent;
  border-bottom: 100px solid #fff;
  border-left: 30px solid transparent;
  border-right: 0px solid #fff;
  position: absolute;
  top: -50px;
  right: 0;
}

.right:before,
{
  content: '';
  line-height: 0;
  font-size: 0;
  width: 0;
  height: 0;
  border-top: 100px solid #fff;
  border-bottom: 50px solid transparent;
  border-left: 0px solid transparent;
  border-right: 30px solid transparent;
  position: absolute;
  top: 0;
  left: 0;
}

.left img,
.right img {
  position: relative;
  width: 100%;
  height: 100%;
  opacity: 0.5;
}

.left img:hover,
.right img:hover {
  opacity: 1;
  cursor: pointer;
}
<div class="left"><img src="./img/chu.jpg"></div>
<div class="right"><img src="./img/chu.jpg"></div>

最佳答案

你可以尝试使用clip-path:

.left,
.right {
  display: inline-block;
  overflow: hidden;
  position: relative;
}

.left {
  border-radius: 10px 0 0 10px;
  -webkit-clip-path: polygon(0 0, 100% 0%, 80% 100%, 0% 100%);
  clip-path: polygon(0 0, 100% 0%, 80% 100%, 0% 100%);
}

.right {
  border-radius: 0 10px 10px 0;
  -webkit-clip-path: polygon(21% 0, 100% 0%, 100% 100%, 0% 100%);
  clip-path: polygon(21% 0, 100% 0%, 100% 100%, 0% 100%);
  margin-left: -40px;
}

img {
  display: block;
}
<div class="left">
  <img src="https://picsum.photos/200/100?image=1069">
</div>
<div class="right">
  <img src="https://picsum.photos/200/100?image=1065">
</div>

这是另一个比使用倾斜变换的 clip-path 更受支持的想法:

.container {
  display: inline-block;
  border-radius: 10px;
  overflow: hidden;
}

.left,
.right {
  display: inline-block;
  vertical-align:top;
  width: 200px;
  height: 100px;
  position: relative;
  transform: skew(-20deg);
  overflow: hidden;
}

.left,
.right img {
  margin-left: -20px;
}

.right {
  margin-right: -20px;
  margin-left: 5px;
}

img {
  display: block;
  transform: skew(20deg);
  width: 110%;
}
<div class="container">
  <div class="left">
    <img src="https://picsum.photos/200/100?image=1069">
  </div>
  <div class="right">
    <img src="https://picsum.photos/200/100?image=1065">
  </div>
</div>

关于html - 带 Angular 边框的 IMG 尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51266545/

有关html - 带 Angular 边框的 IMG 尺寸的更多相关文章

  1. ruby - 使用 ruby​​ 将 HTML 转换为纯文本并维护结构/格式 - 2

    我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h

  2. ruby-on-rails - Rails HTML 请求渲染 JSON - 2

    在我的Controller中,我通过以下方式在我的index方法中支持HTML和JSON:respond_todo|format|format.htmlformat.json{renderjson:@user}end在浏览器中拉起它时,它会自然地以HTML呈现。但是,当我对/user资源进行内容类型为application/json的curl调用时(因为它是索引方法),我仍然将HTML作为响应。如何获取JSON作为响应?我还需要说明什么? 最佳答案 您应该将.json附加到请求的url,提供的格式在routes.rb的路径中定义。这

  3. ruby-on-rails - 使用 Sublime Text 3 突出显示 HTML 背景语法中的 ERB? - 2

    所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择

  4. ruby-on-rails - Ruby url 到 html 链接转换 - 2

    我正在使用Rails构建一个简单的聊天应用程序。当用户输入url时,我希望将其输出为html链接(即“url”)。我想知道在Ruby中是否有任何库或众所周知的方法可以做到这一点。如果没有,我有一些不错的正则表达式示例代码可以使用... 最佳答案 查看auto_linkRails提供的辅助方法。这会将所有URL和电子邮件地址变成可点击的链接(htmlanchor标记)。这是文档中的代码示例。auto_link("Gotohttp://www.rubyonrails.organdsayhellotodavid@loudthinking.

  5. ruby-on-rails - capybara ::ElementNotFound:无法找到 xpath "/html" - 2

    我正在学习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)'

  6. ruby - 如何使用 Ruby 将 CSV 文件读入 HTML 表格? - 2

    我正在尝试将一个简单的CSV文件读入HTML表格以在浏览器中显示,但我遇到了麻烦。这就是我正在尝试的:Controller:defshow@csv=CSV.open("file.csv",:headers=>true)end查看:输出:NameStartDateEndDateQuantityPostalCode基本上我只获取标题,而不会读取和呈现CSV正文。 最佳答案 这最终成为最终解决方案:Controller:defshow#OpenaCSVfile,andthenreaditintoaCSV::Tableobjectforda

  7. ruby - 如何使用 Nokogiri 解析纯 HTML 表格? - 2

    我想用Nokogiri解析HTML页面。页面的一部分有一个表,它没有使用任何特定的ID。是否可以提取如下内容:Today,3,455,34Today,1,1300,3664Today,10,100000,3444,Yesterday,3454,5656,3Yesterday,3545,1000,10Yesterday,3411,36223,15来自这个HTML:TodayYesterdayQntySizeLengthLengthSizeQnty345534345456563113003664354510001010100000344434113622315

  8. ruby-on-rails - 连接字符串时如何在 <%=%> block 内输出 html_safe? - 2

    考虑一下:现在这些情况:#output:http://domain.com/?foo=1&bar=2#output:http://domain.com/?foo=1&bar=2#output:http://domain.com/?foo=1&bar=2#output:http://domain.com/?foo=1&bar=2我需要用其他字符串输出URL。我如何保证&符号不会被转义?由于我无法控制的原因,我无法发送&。求助!把我的头发拉到这里:\编辑:为了澄清,我实际上有一个像这样的数组:@images=[{:id=>"fooid",:url=>"http://

  9. ruby-on-rails - 我需要从 HTML 转到 markdown,有什么建议吗? - 2

    我正在使用Maruku,将Markdown(超集)转换为HTML,你知道我该怎么做才能从HTML转换为Markdown吗? 最佳答案 Google发现了一个名为reverse_markdown的ruby​​脚本.它似乎可以满足您的需求。 关于ruby-on-rails-我需要从HTML转到markdown,有什么建议吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/175162

  10. ruby - 使用 Nokogiri 和 Ruby 从 html 文档获取链接和 href 文本? - 2

    我正在尝试使用nokogirigem提取页面上的所有url及其链接文本,并将链接文本和url存储在散列中。FooBar我想回去{"Foo"=>"#foo","Bar"=>"#bar"} 最佳答案 这是一个单行:Hash[doc.xpath('//a[@href]').map{|link|[link.text.strip,link["href"]]}]#=>{"Foo"=>"#foo","Bar"=>"#bar"}拆分一点可以说更具可读性:h={}doc.xpath('//a[@href]').eachdo|link|h[link.t

随机推荐