Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 位置::在元素上的箭头之后_Javascript_Html_Css_Emotion - Fatal编程技术网

Javascript 位置::在元素上的箭头之后

Javascript 位置::在元素上的箭头之后,javascript,html,css,emotion,Javascript,Html,Css,Emotion,我做了这个,但我无法将箭头定位到元素的左侧: 但我想要这个: 我的css代码: export const ClosedStyled = styled.ul<DropDown>` ${ListItem}:hover & { max-width: 400px !important; max-height: 400px !important; } max-height: 0px !important; overflow: hidden; -w

我做了这个,但我无法将箭头定位到元素的左侧:

但我想要这个:

我的css代码:

export const ClosedStyled = styled.ul<DropDown>`
  ${ListItem}:hover & {
    max-width: 400px !important;
    max-height: 400px !important;
  }
  max-height: 0px !important;
  overflow: hidden;
  -webkit-transition: all 0.2s;
  -moz-transition: all 0.2s;
  -ms-transition: all 0.2s;
  -o-transition: all 0.2s;
  transition: all 0.2s;
  list-style-type: none;
  margin: 0;
  padding: 0;
  top: 0;
  left: 100%;
  font-weight: 400;
  position: absolute;
  padding: 0px;
  z-index: 2;
  background: ${shade(0.4, '#3c8dbc')};
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
  :before {
    content: '';
   position: absolute;
   left: 0px;
   top: 0px;
   width: 0;
   height: 0;
   border-left: 20px solid transparent;
   border-right: 20px solid transparent;
   border-top: 20px solid #000;
   clear: both;
`;
export const ClosedStyled=styled.ul`
${ListItem}:悬停&{
最大宽度:400px!重要;
最大高度:400px!重要;
}
最大高度:0px!重要的
溢出:隐藏;
-webkit转换:所有0.2秒;
-moz转换:全部为0.2s;
-ms转换:均为0.2s;
-o-过渡:均为0.2s;
过渡:均为0.2s;
列表样式类型:无;
保证金:0;
填充:0;
排名:0;
左:100%;
字体大小:400;
位置:绝对位置;
填充:0px;
z指数:2;
背景:${shade(0.4,#3c8dbc')};
边框右上角半径:5px;
边框右下半径:5px;
:之前{
内容:'';
位置:绝对位置;
左:0px;
顶部:0px;
宽度:0;
身高:0;
左边框:20px实心透明;
右边框:20px实心透明;
边框顶部:20px实心#000;
明确:两者皆有;
`;
我在JS中使用css和情感JS,但问题基本上只是css 我使用了
::在
和边框之后,但我不知道如何像示例照片中那样将其翻转过来

例如:


好的,我让它工作了,但有几件事:

  • ClosedStyled
    ,应具有
    display
    属性,而不是宽度和高度,一旦用户悬停,应为display:block,否则应为
    display:none
  • ClosedStyled
    溢出是问题的根本原因,只需将其移除,即可看到箭头
这是一个

或者您可以在此处看到更改的代码:

import styled from "@emotion/styled/macro";
import { shade } from "polished";
import { css } from "@emotion/core";
// Global Containers
const Container = styled.div`
  height: 100%;
`;

const Main = styled.div`
  display: flex;
  height: calc(100% - 55px);
  position: relative;
  z-index: 0;
`;
// Global Containers
export const Global = {
  Container,
  Main
};
// header Nav
export const NavBar = styled.div`
  height: 55px;
  background: #3c8dbc;
  display: flex;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.05), 0 1px 0 rgba(0, 0, 0, 0.05);
  position: relative;
  z-index: 1;
`;

export const LogoSide = styled.div`
  display: flex;
  background: red;
  justify-content: center;
  background: #3c8dbc;
  padding: 10px;
  width: 100%;
  max-width: 250px;
  height: 55px;
  img {
    height: 35px;
    transition: all 0.2s ease;
  }
`;
// header Nav
export const Header = {
  NavBar,
  LogoSide
};
// SideBar
const SideBodyWrap = styled.nav`
  height: 100%;
  max-width: 250px;
  width: 100%;
  color: #009688;
  background: #3c8dbc;
  transition: all 0.2s ease;
  ::-webkit-scrollbar {
    width: 5px;
  }

  ::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  }

  ::-webkit-scrollbar-thumb {
    background: rgba(255, 0, 0, 0.8);
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
  }
  ::-webkit-scrollbar-thumb:window-inactive {
    background: rgba(255, 0, 0, 0.4);
  }
`;

const MenuList = styled.ul`
  font-family: "Ubuntu";
  font-size: 14px;
  font-weight: 300;
  text-decoration: none;
  color: #fff;
  padding-top: 10px;
`;

export const ListItem = styled.li`
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
  position: relative;
`;

export const ListWrap = styled.div`
  padding: 12px 20px 12px 20px;
  display: flex;
  transition: all 0.5s cubic-bezier(0, 1, 0, 1);
  justify-content: center;
  align-items: center;
  a {
    display: flex;
    align-items: center;
    svg {
      margin-right: 15px;
      transition: all 0.5s cubic-bezier(0, 1, 0, 1);
    }
  }
  & .icon-li {
    margin-right: 10px;
  }
  & .down-up_svg,
  .li-name {
    display: none;
  }
`;
export const ClosedStyled = styled.ul`
  ${ListItem}:hover & {
    display: block;
  }
  display: none;
  max-height: 400px !important;
  max-width: 400px !important;
  -webkit-transition: all 0.2s;
  -moz-transition: all 0.2s;
  -ms-transition: all 0.2s;
  -o-transition: all 0.2s;
  transition: all 0.2s;
  list-style-type: none;
  margin: 0;
  padding: 0;
  top: 0;
  left: 100%;
  font-weight: 400;
  position: absolute;
  padding: 0px;
  z-index: 2;
  background: ${shade(0.4, "#3c8dbc")};
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
  :after {
    content: "";
    position: absolute;
    left: -15px;
    top: 8px;
    width: 0;
    overflow: hidden;
    height: 0;
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
    border-right: 15px solid blue;
    clear: both;
    z-index: 11;
  }
  & .li-closed {
    white-space: nowrap;
    padding: 10px 20px;
    :hover > svg {
      color: orange;
    }
    svg {
      margin-right: 10px;
    }
  }
  a {
    font-family: "Ubuntu";
    font-size: 14px;
    font-weight: 300;
    text-decoration: none;
    color: #8aa4af;
  }
`;

const DashMenu = styled.div`
  display: flex;
  flex-direction: column;
`;

export const SideBar = {
  SideBodyWrap,
  DashMenu,
  ClosedStyled,
  ListItem,
  ListWrap,
  MenuList
};
// SideBar

export const Content = styled.div`
  height: 100%;
  width: 100%;
  background: #eee;
`;

你的意思是希望箭头位于元素的右侧?还是指向右侧?我不知道如何解释它,但它与我在问题中放置的照片相同,我需要它位于指向左侧的下拉列表的左侧这里有代码示例:出于某种原因,我设法正确定位箭头,但箭头在Neathbro你能帮我把箭头放在中间的人是谁吗我用-10px这个值我没有得到你需要的东西你能把它添加到沙盒代码中并详细说明一下吗?我用的是同样的代码沙盒,基本上我在my::after中有top:8,它不集中在我的
  • 项中有值
    1px
    会使它居中,我更新了我的代码沙盒,请再次检查:)