【问题标题】:how can I get rid of these dark area when tapping the button on mobile devices在移动设备上点击按钮时如何摆脱这些黑暗区域
【发布时间】:2019-09-01 07:02:41
【问题描述】:

源代码在这里:https://codesandbox.io/s/hony-quekr

演示:https://quekr.csb.app/

按钮本身是一个span 元素。这里是相关代码sn-p。

import React, { Component } from "react";
import posed from "react-pose";
import "./Choice.css";

const config = {
  visible: {
    opacity: 1,
    y: 0,
    delay: 100
  },
  hidden: {
    opacity: 0,
    y: 8,
    delay: 200,
    transition: {
      duration: 200
    }
  }
};
const Underline = posed.div(config);

class Choice extends Component {
  constructor() {
    super();
    this.state = {
      isVisible: false
    };
  }

  componentDidMount() {
    this.setState({ isVisible: this.props.visibility });
  }

  componentDidUpdate(prevProps) {
    if (this.props !== prevProps) {
      this.setState({ isVisible: this.props.visibility });
    }
  }

  render() {
    return (
      <span
        className="word"
        onMouseEnter={() => this.props.onMouseEnter()}
        onMouseLeave={() => this.props.onMouseLeave()}
        onClick={() => this.props.onClick()}
      >
        {this.props.name}
        <Underline
          className="underline"
          pose={this.state.isVisible ? "visible" : "hidden"}
        />
      </span>
    );
  }
}

问题出在移动设备上,当在移动设备上查看页面时,单击(轻按)每个按钮时都会出现一个黑色区域。我附上了一张图片来演示。

我想摆脱这些黑暗区域,这样当你点击这些按钮时除了显示下划线之外什么都不会发生

【问题讨论】:

  • 您的演示在我的 iPhone 上运行良好。正如预期的那样,没有点击文本选择。

标签: javascript html css reactjs


【解决方案1】:

试试这个 CSS:

.no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none; 
  user-select: none;    
}

【讨论】:

    猜你喜欢
    • 2021-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-27
    • 1970-01-01
    • 2016-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多