The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> What is the correct way to create this margin?, Help with margins best practice
JUI43555
post Apr 14 2023, 07:12 AM
Post #1


Member
***

Group: Members
Posts: 44
Joined: 6-March 23
From: Perth
Member No.: 28,833



Hi,

In the screenshot below there is a 165px margin between the main heading and the left hand side (same on the right hand side) What is the best way to write that into my CSS? Is it with the use of margins? Padding for each individual element?

Don't want to add something in the wrong place this early in the build.

Cheers.

IPB Image



CODE
<section class="hero">
                    <div class="hero__content-intro">
                        <h1 class="hero__content-intro--heading">Typemaster keyboard</h1>
                        <p class="hero__content--p">Improve your productivity and gaming without breaking the bank. Upgrade to a high quality mechanical typing experience.</p>
                        <div class="hero__button">
                            <a role="button" href="#">Pre-order now</a>
                            <span>Release on 5/27</span>
                        </div>
                    </div>
                    <div class="hero__image">
                        <img src="images/desktop/image-keyboard.jpg" alt="Typemaster Keyboard - Midnight Grey" />
                    </div>
                </section>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Apr 14 2023, 10:02 AM
Post #2


.
********

Group: WDG Moderators
Posts: 9,661
Joined: 10-August 06
Member No.: 7



To me it looks like padding on div.hero__content-intro would be the simplest, that way you don't need to add left-margins to all its child elements. Other than that I don't think there is a right or wrong way.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
JUI43555
post Apr 14 2023, 09:50 PM
Post #3


Member
***

Group: Members
Posts: 44
Joined: 6-March 23
From: Perth
Member No.: 28,833



QUOTE(Christian J @ Apr 14 2023, 11:02 PM) *

To me it looks like padding on div.hero__content-intro would be the simplest, that way you don't need to add left-margins to all its child elements. Other than that I don't think there is a right or wrong way.


Thanks Christian i'll give it a go
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th April 2024 - 08:57 AM