html - 需要帮助在 CSS 中制作这个标志

标签 html css

我正在尝试重新创建圣卢西亚的这面旗帜。虽然我不知道如何使三 Angular 形居中,但我们将不胜感激!

Here's the flag

@charset "UTF-8";

.blue {
  width: 400px;
  height: 250px;
  background-color: #9EC4E0;
  position: absolute;
  z-index: -1;
}

.triangle-up {
	width: 0;
	height: 50px;
	border-left: 100px solid transparent;
	border-right: 100px solid transparent;
	border-bottom: 200px solid red;
}
	
<!doctype html>
<html>

  <head>
    <meta charset="UTF-8">
    <title>Saint Lucia</title>
    <link href="style.css" rel="stylesheet" type="text/css">
  </head>

  <body>

    <div class="blue">
    <div class="triangle-up"></div>

    </div>


  </body>

</html>

最佳答案

Logo 居中背后的数学原理

left:calc(300px - 200px/2);
top:calc(150px - 200px/2);

上述属性被赋予 .out(标志 block )以及这些特定数字的原因。

宽度逻辑

left:calc("move logo to half of flag width" - "width of triangle" / 2)

高度逻辑

top:calc("move logo to half of flag height" - "height of triangle" / 2)

总的来说,您只是将 Logo 置于旗帜中间。

Provided you know the width and height of the flag.

.arrow-up {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 100px solid transparent;
  border-right: 100px solid transparent;
  border-bottom: 200px solid white;
}

.arrow-up1 {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 90px solid transparent;
  border-right: 90px solid transparent;
  border-bottom: 190px solid black;
  left: 10px;
  top: 10px;
}

.arrow-up2 {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 100px solid transparent;
  border-right: 100px solid transparent;
  border-bottom: 100px solid #f7d117;
  top: 100px;
}

.out {
  left: calc(300px - 200px/2);
  top: calc(150px - 200px/2);
  position: relative;
}

.flag {
  position: relative;
  background: #adcfe6;
  height: 300px;
  width: 600px;
}
<div class="flag">
  <div class="out">
    <div class="arrow-up"></div>
    <div class="arrow-up1"></div>
    <div class="arrow-up2"></div>
  </div>
</div>

关于html - 需要帮助在 CSS 中制作这个标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49562747/

相关文章:

javascript - jQuery 检测滚动条上的 div 位置

php - 为 HTML 编码 mySQL 文本?

javascript - 在选择框上使用 javascript 转到 url |下拉框

jquery - 在每张图片上显示播放按钮和时间

asp.net - CSS 引用问题

隐藏在 JQuery 幻灯片后面的 JQuery 导航栏

javascript - 放大 - 缩小 Javascript 背景上的问题

javascript - 使用 Javascript 我想要一个按钮通过更改 css 来显示或隐藏 div

用于固定图像重叠菜单的 CSS

html - 表格单元格在 IE 中不起作用,知道吗?