PrepAway - Latest Free Exam Questions & Answers

How should you complete the relevant CSS styles?

HOTSPOT
You develop a webpage.
The layout of the webpage must resemble the following image:

You need to ensure that the page renders properly.
How should you complete the relevant CSS styles? (To answer, select the appropriate option from
each drop-down list in the answer area.)

PrepAway - Latest Free Exam Questions & Answers

Answer:

6 Comments on “How should you complete the relevant CSS styles?

  1. Peter says:

    If I look at the JSfiddle, relative seems a better choice for the second span as well.

    It looks more correct compared to the image of how it should look.

    Also, absolute is definetely wrong because: Absolute would place the element depending on how the ancestor was placed (the div). Therefore the element is placed way too far to the right. (It can’t absolute, but not relative either, as the distance is easily more then 100px –> the top should be 200px and it seems the same difference)

    Honestly float: left seems to be the best answer for the second part.




    0



    0
  2. J says:

    IMO The answer is correct. if CSS is left: 100px instead of left:-100px.

    First we need to use relative because we want the content of span1 to show
    in the same position as the normal flow( inline ). A span would appear inline so we use relative without any offset from the normal position to keep the original position.

    Second could be absolute. If we use relative then span2 is not removed from the normal flow which means that we would see a blank space with the size of span2 after “start of span1 contents” . With absolute we completely remove the object from the flow and position the object in relation to the first non static parent which in this case is the span1.




    1



    0
    1. kaggelpiep says:

      The corresponding image is wrong when left: is set to -100px. If you type the HTML and see for yourself the ‘Span2 contents’ is located left of where ‘Start of span1 contents’ is. Then -100px makes sense. Not in this image, where ‘Span2’ contents is not located left of ‘Start of span1’ but directly below it.
      Another stupid question where the answer does not match the image and throws the user off guard.




      1



      0

Leave a Reply