简体   繁体   English

我怎样才能让我的汉堡菜单更小,并在它周围有一个完美的圆形边框?

[英]How can I make my hamburger menu smaller and also have a perfect circular border around it?

I'm trying to make my hamburger menu smaller (both height and width), and I've been trying for awhile and made it a bit smaller but for some reason can't figure out how to make it any smaller.我正在尝试使我的汉堡菜单更小(高度和宽度),并且我已经尝试了一段时间并使其更小但由于某种原因无法弄清楚如何使其更小。 I also am struggling with trying to make a perfect circle border around it.我也在努力尝试在它周围制作一个完美的圆形边框。 Can someone help me out?有人可以帮我吗? I found this code in a codepen and have adjusted it a bit, but I'm struggling to make it just right.我在 codepen 中找到了这段代码并对其进行了一些调整,但我正在努力让它恰到好处。

jsfiddle: https://jsfiddle.net/annahisenberg/ft10ersb/6/ jsfiddle: https://jsfiddle.net/annahisenberg/ft10ersb/6/

JS Code: JS代码:

class Drag extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      x: this.props.x,
      y: this.props.y,
      showMoreOptionsPopup: false,
      showHelpModal: false
    };

    this.reff = React.createRef();

    this.dragMouseDown = this.dragMouseDown.bind(this);
    this.elementDrag = this.elementDrag.bind(this);
    this.closeDragElement = this.closeDragElement.bind(this);
    this.showMoreOptionsPopup = this.showMoreOptionsPopup.bind(this);
  }


  componentDidMount() {
    this.pos1 = 0;
    this.pos2 = 0;
    this.pos3 = 0;
    this.pos4 = 0;
  }

  dragMouseDown(e) {
    e.preventDefault();
    this.pos3 = e.clientX;
    this.pos4 = e.clientY;
    document.onmouseup = this.closeDragElement;
    document.onmousemove = this.elementDrag;
  };

  elementDrag(e) {
    e.preventDefault();
    this.pos1 = this.pos3 - e.clientX;
    this.pos2 = this.pos4 - e.clientY;
    this.pos3 = e.clientX;
    this.pos4 = e.clientY;
    this.setState({
      y: this.reff.current.offsetTop - this.pos2 + "px",
      x: this.reff.current.offsetLeft - this.pos1 + "px"
    });
  };

  closeDragElement() {
    document.onmouseup = null;
    document.onmousemove = null;
  };

  showMoreOptionsPopup() {
    this.setState({
      showMoreOptionsPopup: !this.state.showMoreOptionsPopup
    });
  };

render() {
    return (
      <div>
        {this.state.showMoreOptionsPopup && (
          <div
            id="more_options_popup"
            style={{
              left: this.reff.current.offsetLeft - 170 + "px",
              top: this.reff.current.offsetTop - 130 + "px"
            }}
          >
           <p>Help Doc</p>
           <p>Help Doc 2</p>
           <p>Help Doc 3</p>
          </div>
        )}

            <a
          id="more_options_button"
          className={this.state.showMoreOptionsPopup ? 'open' : null}
          onClick={this.showMoreOptionsPopup}
          style={{ left: this.state.x, top: this.state.y }}
          onMouseDown={this.dragMouseDown}
          ref={this.reff}
        >
          <div></div>
        </a>
      </div>
    );
  }
}

css: css:

#more_options_button {
    display: block;
    /* position: absolute; */
    width: 50px;
    height: 50px;
    /* top: 50%; */
    /* left: 50%; */
    position: fixed;
    bottom: 149px;
    right: 63px;
    cursor: pointer;
    transform: translate(-50%, -50%);
    z-index: 9999;
}

#more_options_button.open div {
    background: none;
}

#more_options_button.open div:before, #more_options_button.open div:after {
    top: 0;
}

#more_options_button.open div:before {
    -webkit-transform: rotate(-45deg);
    transform: rotate(-45deg);
}

#more_options_button.open div:after {
    -webkit-transform: rotate(45deg);
    transform: rotate(45deg);
}

/* #more_options_button:hover:not(.open) div:before {
    top: -10px;
}

#more_options_button:hover:not(.open) div:after {
    top: 10px;
} */

#more_options_button div,
#more_options_button div:before,
#more_options_button div:after {
    width: 100%;
    height: 4px;
    background: #222222;
    -webkit-transition: all 0.4s ease;
    -moz-transition: all 0.4s ease;
    -o-transition: all 0.4s ease;
    transition: all 0.4s ease; 
}

#more_options_button div {
    position: relative;
    margin: 20px auto 0;
}

#more_options_button div:before, div:after {
    content: "";
    position: absolute;
}

#more_options_button div:before {
    top: -20px;
}

#more_options_button div:after {
    top: 20px;
}


@keyframes modalFade {
      from {transform: translateY(-50%);opacity: 0;}
      to {transform: translateY(0);opacity: 1;}
}

#more_options_popup {
    position: absolute;
    /* bottom: 201px; */
    /* right: 66px; */
    text-align: right;
    z-index: 9999;
    animation-name: modalFade;
    animation-duration: .3s;
}

#more_options_popup p {
    cursor: pointer;
}

.more_options_icons {
    border-radius: 50% !important;
    border: 1px solid black;
    height: 1.5rem;
    width: 1.5rem;
    text-align: center;
}


#close_help_modal {
    z-index: 9999;
}

.help_icon_ctnr {
    display: flex;
}

.help_popup_grid_col {
    border-right: none !important;
}

.help_popup_grid_col p {
    margin-right: 1rem;
}

You'd have to tweak all of the appropriate CSS properties to get the size you're looking for.您必须调整所有适当的 CSS 属性以获得您正在寻找的大小。 You have them spread out over a lot of different rules and are using absolute positioning/margins in a strange way so it's not straightforward, but I made a basic attempt here你让它们分布在许多不同的规则上,并且以一种奇怪的方式使用绝对定位/边距,所以这并不简单,但我在这里做了一个基本的尝试

You need to reduce the width of the main menu div, the height of its pseudo elements, as well as reduce their margin and the margins you're using to position it inside the div, then add a border.您需要减少主菜单 div 的width ,其伪元素的height ,以及将它们的边距和您使用的边距减少到 position 它在 div 内,然后添加边框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM