如何最好地创建此箭头形的div /按钮?

时间:2019-05-02 09:45:15

标签: html css sass

Stack上的第一篇文章。我被要求为项目重新创建该设计,但我不确定是否最好以这种方式重新创建带有箭头底部的div / button。

image of button with non-rectangular polygon shape

我对大多数CSS约定都相当满意,但是对于像这样的自定义样式,我有点不了解起点。如果有人能指出正确的方向,我将不胜感激。

非常感谢, 内森

2 个答案:

答案 0 :(得分:1)

.button
{
    position: relative;
    background-color: rgb(128,250,128);
    padding: 10px 0px;
    width: 60px;
    text-align: center;
}
.button::after
{
    display: block;
    position: absolute;
    bottom: -10px;
    content: "";
    width: 0px;
    border-color: rgb(128,250,128) transparent;
    border-style: solid;
    border-width: 10px 30px 0px 30px; /*10 is the height and 30 is half of parent width*/
}
<div class="button">
  button
<div>

答案 1 :(得分:1)

这是您需要使Dir.mktmpdir do |dir| xcbuild( workspace: "#{project_name}.xcworkspace", scheme: "#{project_name}", configuration: "Debug", xcargs: "-sdk iphonesimulator SYMROOT=#{dir}" ) app_path = sh("find #{dir} -name *.app -type d").strip() sh("mv #{app_path} #{options[:output_directory]}/#{app_identifier}.app") end 向下倾斜的CSS:

div/button
.menu {
  background-color: #0b0;
  border: 1px solid #000;
  float: left;
  height: 50px;
  line-height: 50px;
  margin: 0;
  position: relative;
  text-align: center;
  width: 150px;
}
.menu.active {
background-color: #0d0;
}
.menu.active::after {
  border-top: 10px solid #0d0;
  border-left: 75px solid transparent;
  border-right: 75px solid transparent;
  bottom: -10px;
  content: "";
  left: 0;
  position: absolute;
}
.menu.active::before {
  border-top: 10px solid #000;
  border-left: 75px solid transparent;
  border-right: 75px solid transparent;
  bottom: -11px;
  content: "";
  left: 0;
  position: absolute;
}