Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

243
Visualizações
CSS/React My button moves out of place when minimizing window

Trying to make a generic search bar in React, having trouble preventing the search button from moving when minimizing the window. The arrow will always move out of position when I minimize the window even if just a bit, wondering what I am missing in my code. I want the search arrow button to maintain its place even when minimizing the window but it keeps moving.

Searchbar.js

import React from "react";
import './SearchBar.css';
import arrow from './arrow.png';

const SearchBar = ({placeholder,data}) => {
    return (
        <div className="search">
                <div className="searchInputs">
                    <input type="text" placeholder={placeholder}/>
                    <button className='button' style={{position: 'relative',
                                                right: 420, top: 15}}>
                    <img className='arrow' src={arrow} alt="logo" 
                        style={{position: 'relative', right: 15, bottom: 11}}
                    ></img>                            
                                                </button>
                    <div className="searchIcon"></div>
                </div>
                <div className="dataResult"></div>
        </div>
    );
}

export default SearchBar;

Searchbar.css

.searchInputs {
  margin-top: 55px;
  display: flex;
  position: relative;
}

.search input {
  background-color: white;
  border: 0;
  border-radius: 40px;
  font-size: 16px;
  height: 72px;
  width: 676px;
  margin: auto;
  font-family: Proxima Nova,Arial,sans-serif;
  font-weight: 700;
  line-height: 1.33;
  
  color: #414141;
}


input:focus {
  outline: none;
}

.searchIcon svg {
  font-size: 16px;
}

.button {
  display: flex;
  flex-direction: row;
  align-items: left;
  height: 10px;
  width: 10px;
  border-radius: 50%;
  border: none;
  padding: 20px;
  background-color: #428a13;
  transition: background-color .2s;
  
}

.arrow {
  height: 24px;
  width: 31px;
}

.button:hover {
  color: rgba(255, 255, 255, 1);
  box-shadow: 0 0px 22px orange;
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

That's because you put position:relative in button element. When you minimize Browser, the button moves to the coordinates you put from one of its element having position: relative. (if you didn't put position :relative to its parents, the button moves from the body element.).

This is why the trouble happened and if you wanna control this, you should remove the position value as code below and position the button with display flex options.

 <button className='button' >
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda