简体   繁体   English

pac-container 反应自动完成 - 我如何引用 CSS

[英]pac-container react autocomplete - how do i reference the CSS

I'm trying to change the pac-container for my google autocomplete component.我正在尝试为我的 google 自动完成组件更改 pac-container。 I want to style this pac-container, but I have no idea how to reference the css of the already defined class name.我想设置这个 pac 容器的样式,但我不知道如何引用已经定义的 class 名称的 css。

Here's my code这是我的代码

...
    constructor(props) {
        super(props);
        this.state = {
            address_ignore_autofill: this.props.address,
        };
        this.autocomplete = null;
    }

    componentDidMount() {
        this.autocomplete = new 
google.maps.places.Autocomplete(document.getElementById('address'), {});
        this.autocomplete.addListener("place_changed", this.handlePlaceSelect)
    }

    handleFormChange = (event) => {
        this.setState({ address_ignore_autofill: event.target.value });
    };

    render() {
        const { classes } = this.props;
        return (
            <TextField
                onChange={(e) => this.handleFormChange(e)}
            />
        );
    }

Where am i supposed to modify .pac-container?我应该在哪里修改.pac-container? . . I've tried modifying right in index.css but that isn't working.我尝试在index.css中进行修改,但这不起作用。 I've also tried wrapping my <Textfield/> class in a div and doing我还尝试将我的<Textfield/> class 包装在一个div中并做

import './test.css'

<div className='test'>
  <Textfield>
</div>

and

this is test.css

.test .pac-container {
    margin-top: 500
}

but that didn't work either.但这也没有用。

Doing正在做

 .pac-container {
    margin-top: 500
}

didn't work either.也没有用。

I know I'm missing something incredibly stupid.我知道我错过了一些非常愚蠢的东西。 Please help.请帮忙。 Thanks谢谢

you need to include the unit in your margin-top value您需要将该单位包含在您的保证金最高值中

.pac-container {
    margin-top: 500px;
}

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

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