- This topic is empty.
-
AuthorPosts
-
May 15, 2015 at 12:43 am #202326MaxParticipant
Hello!
I can not understand why <h1>Welcome to Our Website!</h1> is aligned right, there are no margins, paddings and positioning, etc. I do not understand why it sticks right. Please, help! It should be on the left.
Full code http://codepen.io/maxwl/pen/MwyxLN
HTML http://codepen.io/maxwl/pen/MwyxLN.html
CSS http://codepen.io/maxwl/pen/MwyxLN.cssMay 15, 2015 at 1:34 am #202328Paulie_DMemberIt’s because of this
.mainContent { float: right; }
Remove the float.
May 15, 2015 at 1:45 am #202329MaxParticipantThanks, but you can not do that. The page layout will be broken. The mainContent should be floated right.
May 15, 2015 at 1:54 am #202332MaxParticipantI cooked the page layout in accordance with the book “CSS3: The Missing Manual” by David Sawyer McFarland. What have I done wrong? May be I misunderstood something?
May 15, 2015 at 2:00 am #202333Paulie_DMemberWhat have I done wrong? May be I misunderstood something?
Can’t tell, what is it supposed to look like?
May 15, 2015 at 2:21 am #202335MaxParticipantOk, thanks. But are there other solutions?
I did so as McFarland recommends it:
“Avoid setting a width for the main content div. It’s not necessary, since browsers simply expand it to fit the available space. Even if you want a fixed-width design, you don’t need to set a width for the main content div, as you’ll see in the next section”
I try not to set width for the main content.
May 15, 2015 at 2:36 am #202336Paulie_DMemberI’m not going to read a book I don’t have to explain his reasoning…if you float that div it will collapse around it’s content unless you give it an explicit width.
I’d suggest that you check back carefully over all the steps you have taken so far and make sure you haven’t missed something.
May 15, 2015 at 2:51 am #202338Paulie_DMemberOf course, if you change the order of the elements…
May 15, 2015 at 2:52 am #202339tomhanson1985ParticipantI tried removing float: right and adding display: inline-block instead to .mainContent. how does that look?
May 15, 2015 at 3:08 am #202340Paulie_DMemberLooks fine to me, but I’m sure all will be explained further in the book.
May 15, 2015 at 3:11 am #202341MaxParticipantAfter I tried to give the div .mainContent a width it caused new problems.
You solution to remove float and add display inline-block looked very good untill I added a new div inside the div .mainFeature right under h1. Please, have a look:
May 15, 2015 at 3:28 am #202342Paulie_DMemberYou solution to remove float and add display inline-block
Not my solution, yours.
My suggestion was…
I’d suggest that you check back carefully over all the steps you have taken so far and make sure you haven’t missed something.
If you haven’t missed something then you need to either continue reading to make sure this behaviour is explained further.
May 15, 2015 at 3:47 am #202343MaxParticipant“I’d suggest that you check back carefully over all the steps you have taken so far and make sure you haven’t missed something.”
Thank you. It’s a very good advice. You are very good at css and helped me a lot with my code. Have a nice day!
May 15, 2015 at 4:30 am #202344Paulie_DMemberI can’t be that good…I’m missing something, I’m sure of it.
There is a solution for this, I just can’t find it….assuming that your
float:right
was suggested by the book.May 20, 2015 at 4:34 am #202579MaxParticipantHi, thanks for time and efforts, the solution is here
https://forums.digitalpoint.com/threads/h1-aligned-right-and-i-cant-move-it-left.2754558/ -
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.