Как переместить кнопку в html?
Хочу переместить кнопку в право, но как это делать? И как ещё убрать линии на кнопке?
P.s хотел ещё спросить. Как сделать задний фон этой шапки другим цветом? допустим красным
- Вопрос задан более двух лет назад
- 5100 просмотров
- Вконтакте

С помощью CSS. В данном кейсе для смещения кнопки отлично подойдет flex, с марджином или space-between-ориентацией.
А фон просто через background-color.
- Вконтакте


- Вконтакте

Линии убрать border:none;
А переместить так же как и любой другой объект с помощью маржинов и пэдингов.
Можете задать position: absolute ;
и переместить с помощью top ,bottom,left ,right
только нужно задать родителю position к примеру relative
HTML how to move the button to the right
Sorry, if the question is dumb because I am just a beginner in HTML. How to move my button to the right? I have tried some ways but it doesn’t seem to work. Here is my code.
![]()
7 Answers 7
Many ways how to do that, for example float
![]()
With the help of CSS float property, you can align elements accordingly. Demo
![]()
You can also move you button to right by applying text-align: right; to it’s parent. In your case it’s parent is body.
So you can apply css like:
Note: It make your p tag also align to right.
![]()
Depending on how much space you want to move it to the right add this to .button_example:
![]()
You can also do it as a percentage:
It will move when resizing the page, whereas with pixels it will try to stay at 100px from the left of the page. It all depends on the result you want when resizing the window.
I found for my button I had to use:
Obviously, play around with your own right px, and do it on the developer tools in the browser to get it perfect, but that is what worked for me.
![]()
-
The Overflow Blog
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.5.24.43458
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.