Fórum Problema ao centralizar botões na página (CSS/HTML) #621067

27/02/2024

0

Gente, to quebrando cabeça pra poder fazer com que alguns botões fiquem centralizados. Não entendo nada de CSS/HTML. Alguém consegue me orientar? :c

No momento está assim:
https://i.imgur.com/RT2AJi9.png

Quero que fique assim PORÉM CENTRALIZADO (não consigo deixar centralizado!!! já tentei de tudo!)
https://i.imgur.com/Y2WNaKZ.png

Já alterei tudo do a.link button mas não consigo por nada deixar isso no meio, só fica assim no canto!

index.html:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<section class="botoes-links">
    <a href="#" target="_blank" class="link">
        <button class="degrade">
            <span><center><b>Instagram</b></center></span>
            <i class="bi bi-instagram"></i>
        </button>
    </a>
 
    <a href="#" target="_blank" class="link">
        <button class="degrade">
            <span><center><b>Tiktok</b></center></span>
            <i class="bi bi-tiktok"></i>
        </button >
    </a>
 
    <a href="#" target="_blank" class="link">
        <button class="degrade">
            <span><center><b>Livros</b></center></span>
            <i class="bi bi-book"></i>
        </button>
    </a>
                <a href="#" target="_blank" class="link">
        <button class="degrade">
            <span><b>Telegram</b></span>
            <i class="bi bi-telegram"></i>
        </button>
    </a>
                <a href="#" target="_blank" class="link">
        <button class="degrade">
            <span><b>WhatsApp</b></span>
            <i class="bi bi-whatsapp"></i>
        </button>
    </a>
     
</section><!--botoes-links-->


css:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: ''Outfit'', sans-serif;
}
 
html{
    height: 100vh;
    font-size: 14px;
}
 
body{
    background-color: #282828;
    height: 100%;
}
 
.container{
    height: 100%;
    max-width: 550px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px;
    color: #fff;
}
 
a{
    text-decoration: none;
    color: #fff;
}
 
.degrade{
    background: linear-gradient(to right, #42a8b7, #49b0bf);
}
 
.fundog{
    background: linear-gradient(to right, #17a0a5, #10ebe1);
}
 
.imgf {
    width: 80%;
    max-width: 100%;
    opacity: 1;
    border-style: solid;
    border-width: 5px 5px 5px 5px;
    border-color: #F4AF1B;
    border-radius: 500px 500px 500px 500px;
    box-shadow: 0px 0px 67px -6px #A98000;
}
 
/* ESTILO DO HEADER */
 
header{
    text-align: center;
    margin-bottom: 40px;
}
 
header img{
    max-width: 180px;
    margin-bottom: 20px;
    border-radius: 50%;
}
 
header h1{
    font-size: 2em;
    margin-bottom: 10px;
    color: #5e5e5e;
    font-weight: 300;
}
 
/* ESTILO DOS BOTÕES */
 
section.botoes-links{
    display: flex;
    flex-direction: column;
    gap: 20px;
}
 
a.link button{
    width: 100%;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: none;
    border-radius: 30px;
    font-size: 1.2em;
    cursor: pointer;
    color: #fff;
    transition: .2s;
}
 
a.link i{
    font-size: 1.5em;
}
 
a.link button:hover, footer a.btn-footer:hover{
    transform: scale(1.05);
}
 
/* ESTILO DO FOOTER */
 
footer{
    text-align: center;
    margin: 30px;
}
 
footer a.btn-footer{
    width: 60px;
    height: 60px;
    display: inline-block;
    font-size: 2em;
    line-height: 60px;
    border-radius: 50%;
    margin: 0 10px;
    transition: .2s;
}


E para deixar como a segunda imagem, eu alterei o
1
2
a.link button{
    width: 100%;


para
1
2
a.link button{
    width: 35%;


Mas não consigo deixar essa bomba no meio!!! Como posso fazer isso?

Obrigada!!
Larissa Vieira

Larissa Vieira

Responder

Posts

05/03/2024

Diego Marinho

Se você quer centralizar os buttons, vc tem duas opções

1 - Nos parâmetros do seu css, do a.link button , vc precisa inserir o "margin: auto" , assim :
[code=css

a.link button{
margin: auto
}

][/code]

2 - Você pode fazer o mesmo inserindo o "align-items: center", nos parâmetros do section.botoes-links, assim :
1
2
3
4
section.botoes-links{
    
    align-items: center;
}



Porém isso centralizará os os buttons no meio da tela, se for isso que você quer.... só precisará inserir uma das duas opções acima, mas se vc quer deixar igual a segunda imagem que vc postou acima, pra isso, além de colocar os parâmetros acima, vc precisaria mudar o width do a.link button para mais ou menos 200px e o width: do section.botoes-links para mais ou menos - 40vw;

esses dois blocos de código ficaria assim :


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
section.botoes-links{
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    width: 40vw;
}
  
a.link button{
    width: 200px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: none;
    border-radius: 30px;
    font-size: 1.2em;
    cursor: pointer;
    color: #fff;
    transition: .2s;
}


Talvez seja isso que vc esteja querendo ...
Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar