html - 如何使用css来进行这样的设计?

标签 html css

我正在尝试做这个设计,但没有取得任何成功?我无法克服这个问题任何帮助将是可观的

我正在附上我想要的设计的图像

enter image description here

这是我尝试过的代码

.auth__container {
    min-height: 70%;
    width: 50%;
    margin: 2rem;
    border-radius: .4rem;
    background-color: #fff;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.075);
    -webkit-transition: all .5s ease;
    transition: all .5s ease;
}

.auth__nav {
    list-style: none;
    margin-left: 10%;
    padding: 0;
    background: #e8e6e6;
    width: 50%;
    
}

.auth__nav-heading {
    width: 50%;
    background-color: #e42a70;
    position: relative;
    top: 0;
    left: -1rem;
    height: 4rem;
    color: #fff;
}

.auth__nav-heading:before {
    border-width: 0 1rem 1rem 0;
    border-color: transparent blue;
    left: 0;
    bottom: -1rem;
}  
<ul class="auth__nav"><li class="auth__nav-item auth__nav-heading">Sign up</li><li class="auth__nav-item">Login</li></ul>

我希望边框底部应该像我标记的图像中那样指向,但我没有明白,任何人都可以帮我解决这个问题吗?

最佳答案

您可以使用具有 position:absolute 的 css 三 Angular 形 #triangle 来实现:

.auth__container {
    min-height: 70%;
    width: 50%;
    margin: 2rem;
    border-radius: .4rem;
    background-color: #fff;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.075);
    -webkit-transition: all .5s ease;
    transition: all .5s ease;
}

.auth__nav {
    list-style: none;
    margin-left: 10%;
    padding: 0;
    background: #e8e6e6;
    width: 50%;
    
}

.auth__nav-heading {
    width: 50%;
    background-color: #e42a70;
    position: relative;
    top: 0;
    left: -1rem;
    height: 4rem;
    color: #fff;
}

.auth__nav-heading:before {
    border-width: 0 1rem 1rem 0;
    border-color: transparent blue;
    left: 0;
    bottom: -1rem;
}  

#triangle {
  position: absolute;
  top: 100%;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 1rem 1rem 0;
  border-color: transparent #e42a70 transparent transparent;
}
<ul class="auth__nav">
  <li class="auth__nav-item auth__nav-heading"><span id="triangle"></span>Sign up</li>
  <li class="auth__nav-item">Login</li>
</ul>

关于html - 如何使用css来进行这样的设计?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59704763/

相关文章:

javascript - 如何与youtube.com上的YouTube播放器(而非iFrame API)互动?

javascript - 当网格底部有空白时,Bootstrap + Masonry 添加空白 div

html - CSS中具有多种颜色渐变的文本

javascript - 当我缩小页面时,类 "rcorners2"的框在某些部分离开了页面。我该如何解决这个问题,以便它顺利缩小?

css - 为什么更改一个内联 div 的垂直对齐方式只会影响一个单独的内联 div?

html - 定位固定时iOS移动背景图像

css - 保持 Popover 相对于按钮居中

javascript - 停止输入提交表单 - 得到奇怪的结果

javascript - 复选框切换所有与 jquery 触发器功能

javascript - 将svg中的样式标签和xml嵌入到html页面中可以吗?