简体   繁体   English

我想在我的网络中放置一个三角形并用图像填充它

[英]I would like to have a triangle in my web and filled it with images

I'm designing a little web page, just for practicing(I'm a begginer), and as the title says, I need to create a triangle with a background image. 我正在设计一个用于练习的小网页(我是个初学者),正如标题所述,我需要创建一个带有背景图像的三角形。 I have this model that I created : My website 我创建了这个模型: 我的网站

I'm talking about the triangles on the up-right corner of the "posts" 我说的是“柱子”右上角的三角形

The only way I know of creating a triagle is with borders in CSS, but that won't help because of the image I need to use. 我知道创建triagle的唯一方法是在CSS中使用边框,但是由于需要使用图像,因此这无济于事。

Maybe you have other idea Thanks ! 也许您还有其他想法,谢谢!

Tell me if you need help getting this in to your own code, here's the example: 告诉我,如果您需要帮助将其输入自己的代码中,请参见以下示例:

 div { position: absolute; width: 128px; height: 128px; background-image: url(http://i.imgur.com/envk4PP.png); background-repeat: no-repeat; background-size: cover; -webkit-clip-path: polygon(0 12%, 0 86%, 35% 50%); clip-path: polygon(0 0%, 100% 100%, 100% 0%); } 
 <div></div> 

I have to do something similar for a website, this is my example. 我必须为网站做类似的事情,这是我的例子。 I hope you can use it. 希望您可以使用它。

 .overheader{ padding: 40px 0; -webkit-clip-path: polygon(0 0, 0% 0, 20.3% 100%, 0% 100%); -moz-clip-path: polygon(0 0, 0% 0, 20.3% 100%, 0% 100%); clip-path: polygon(0 0, 0% 0, 20.3% 100%, 0% 100%); background-image: url('http://www.todofermentacion.cl/assets/img/cerveza.png'); } .page-header { padding: 50px; } 
 <div class="page-header"> <div class="overheader"> </div> </div> 

You have to modify the parameters of polygon to make the triangle anyway you want 无论如何,您都必须修改多边形的参数以使三角形成为可能

Another option: 另外一个选项:

 .post { /* not important */ margin: 100px; width: 10rem; height: 5rem; border: solid 1px black; background: ivory; padding: 1rem; /* important */ position: relative; overflow: hidden; } .post:after { position: absolute; display: block; content: " "; background-image: url(https://www.gravatar.com/avatar/614f3577183f1a9219884f73ec2538fd); transform: rotate(45deg); width: 50px; height: 50px; /* move it half the width*/ top: -25px; right: -25px; } 
 <div class="post"> Here is my post </div> 

 :root{ --imageblockwidth: 105px; --imageblockheight: 80px; /*css variables*/ } .imagediv { width: var(--imageblockwidth); height: var(--imageblockheight); background-image: url(https://i.ytimg.com/vi/2fb-g_V-UT4/hqdefault.jpg); background-size: contain; background-repeat: no-repeat; } .imageoverlapper { width: var(--imageblockwidth); height: var(--imageblockheight); box-sizing: border-box; /*triangles using borders*/ border-top: var(--imageblockheight) solid rgba(0,0,0,0); border-left: var(--imageblockwidth) solid yellow; position: relative; top : calc(-1*var(--imageblockheight)); } 
 <div class="imagediv"></div> <div class="imageoverlapper"></div> 

Just overlap rectangle with background image by triangle 只是将矩形与背景图像按三角形重叠

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想以“波浪”形式加载图像。 - I would like to load images in a “wave”.. 当我单击编辑图像时,我希望我的编辑功能能够正常工作 - I would like to have my edit function to work when i click on the edit image 我已经下载了最新版本的 Gradle 7.3,我想在我的 Visual Studio 项目 EXPO 中使用它 - I have downloaded the latest version of Gradle 7.3 that I would like to use in my Visual studio project EXPO 我需要帮助修复我的代码 - I would like assistance in fixing my code 我想停止倒数计时器 - I would like to stop my countdown timer 我想在我的网站的代码示例中添加行号。 我想通过CSS(生成的内容?)或javascript来完成此操作 - I would like to add line numbers to code samples on my web site. I would like to do this either thru CSS (generated content?) or javascript 已为单个图像创建了点击效果,但希望其他图像具有相同的效果 - Have created a click effect for a single image, but would like to have the other images have the same effect 我有一个文本框,我希望用户单击按钮时可以切换到网格。 在asp.net中可以吗? - I have a textbox which I would like to allow my users to switch to a grid when they click a button. Is this possible in asp.net? 我有JSON数据,我想在Full Calender上显示 - I have JSON data and I would like to show that on Full Calender 对于一系列图片,我希望每个图像都有不同的音频 - With an array of pictures I would like to have a different audio for each image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM