Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Alignment

Enthusiast ,
Jun 04, 2019 Jun 04, 2019

Hi,

In "Tablet View", I want to move the orange box to the right.

How would I do?

Link

Hosuns Portfolio 3

Hosun Kang

Q_Dw_20_alignment.png

424
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 04, 2019 Jun 04, 2019

.box2 {

    height: 24px;

    height: auto:

    width: 80px;

    background-color: orangered;

    margin-top: 16px;

    display: flex;

    justify-content: center;

    align-items: center;

    float: right;

}

Translate
Community Expert ,
Jun 04, 2019 Jun 04, 2019

.box2 {

    height: 24px;

    height: auto:

    width: 80px;

    background-color: orangered;

    margin-top: 16px;

    display: flex;

    justify-content: center;

    align-items: center;

    float: right;

}

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 05, 2019 Jun 05, 2019

Hi,

Thank you very much for your reply.

I have one more question.

In your reply, there is

height: auto;

I kept

height: 24px;

There is no difference to me.

What's the difference between "height: auto;" and "height: 24px;"?

Hosun Kang

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 05, 2019 Jun 05, 2019

Hosun  wrote

Hi,

Thank you very much for your reply.

I have one more question.

In your reply, there is

height: auto;

I kept

height: 24px;

There is no difference to me.

What's the difference between "height: auto;" and "height: 24px;"?

Hosun Kang

Setting height on a <div> which contains text is NOT desirable because if an end-user enlarges the text in their browser the text will eventually disappear from view. The height of the <div> stays the same and therefore in some circumstances cannot show the text as it gets larger. It's always best to let the 'text content' of a <div> find its own height naturally unless you set a scroll on the <div>, which should be used sparingly.

As an aside note using 'float' to position elements is a bit of an old workflow these days. It still works but try and implement 'flex' as much as possible as it has a lot better variations and you should get used to it going forward where possible.

.box2 {

margin-top: 16px;

display: flex;

justify-content: flex-end;

}

.box2 a {

background-color: orangered;

color: #fff;

padding: 10px;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 05, 2019 Jun 05, 2019

Hi,

Thank you very much for your info.

I tried to put in your instruction.

But it doesn't work to me.

Hosun Kang

Hosuns Portfolio 3

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 05, 2019 Jun 05, 2019

Remove height value from box1.

Add float:right  to box2.

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 05, 2019 Jun 05, 2019
LATEST

Hosun  wrote

Hi,

Thank you very much for your info.

I tried to put in your instruction.

But it doesn't work to me.

Hosun Kang

Hosuns Portfolio 3

For desktop start off with:

.box2 {

    margin-top: 16px;

}

.box2 a {

    text-decoration: none;

    color: white;

    padding: 0px 6px;

    background-color: orangered;

}

Then tablet:

/*Tablet View*/

@media (max-width: 1024px) {

   .box1 {

   text-align: center;

}

.box2 {

   display: flex;

   justify-content: flex-end;

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines