我的网站上需要导航菜单,所以我在网上搜索某个选项,在Codepen中找到了一个选项,然后复制粘贴到我的文本编辑器中,看到了预览,但是代码在预览中无法正常运行。
这里是codepen editor的链接的附件:
我希望在文本编辑器中的预览中从代码笔获得相同的输出
html,
body {
font-family: sans-serif;
font-size: 14px;
color: #555555;
height: 100%;
width: 100%;
margin: 0;
}
.container {
left: 50%;
top: 50%;
position: absolute;
transform: translate(-50%, -50%);
}
.selector {
padding: 0.25rem;
background-color: #efefef;
width: min-content;
border-radius: 12px;
position: relative;
}
.selector-item {
white-space: nowrap;
padding: 0.75rem 1.5rem;
cursor: pointer;
z-index: 2;
user-select: none;
transition: color 0.2s ease;
}
.selector-item--active {
color: white;
}
.highlight {
background-color: #ff4757;
border-radius: 8px;
position: absolute;
left: 0.25rem;
width: 4.75rem;
height: 2.6rem;
z-index: 1;
box-shadow: 0px 0px 12px -2px rgba(255, 71, 86, 0.9);
transition: left 0.2s ease,
width 0.2s ease;
}
<div class="container">
<div class="selector" self="size-x1" layout="row center-left">
<div class="highlight"></div>
<div class="selector-item" onclick="selectItem(event)">Chapter-wise</div>
<div class="selector-item" onclick="selectItem(event)">Year-wise</div>
<div class="selector-item" onclick="selectItem(event)">Others</div>
</div>
</div>
答案 0 :(得分:0)
您需要在页面中添加以下参考。
https://cdnjs.cloudflare.com/ajax/libs/flex-layout-attribute/1.0.3/css/flex-layout-attribute.min.css