CSS Arranging order of elements when screen width changes it's properties

php die

I have my page setup in rows with differing column widths. For example:

<div class="row">
  <div class="span6">Left side</div><!-- 50% width -->
  <div class="span6">Right side</div><!-- 50% width -->
</div>

I have properties in place so that on a narrow screen width, each column will be 100% width. This, of course, makes the "right side" appear below the "left side" due to the order it appears on the page.

I'm trying to find out if there is ANY WAY to add a class or something to the "right side" div so that if the screen width makes each column 100% width, the right side will appear ABOVE the left side, and not below.

Preferably I'd like to do this with only CSS, but if I have to use jQuery I can do that as well.

.row { 
width:100%; 
margin:0 auto; 
}

.span1 { width:8.33%; }

.span2 { width:16.66%; }

.span3 { width:25%; }

.span4 { width:33.33%; }

.span5 { width:41.66%; }

.span6 { width:50%; }

.span7 { width:58.33%; }

.span8 { width:66.66%; }

.span9 { width:75%; }

.span10 { width:83.33%; }

.span11 { width:91.66%; }

.span12 { width:100%; }

.span1-5 { width:20%; } /* This column can be used as a one fifth of the row */

.span1-8 { width:12.5%; } /* This column can be used as a one eigth of the row */ 

.span1, 
.span2, 
.span3, 
.span4, 
.span5, 
.span6, 
.span7,
.span8, 
.span9, 
.span10, 
.span11, 
.span12, 
.span1-5, 
.span1-8 {
  min-height: 1px; 
  float: left; 
  padding-left: 10px; 
  padding-right: 10px; 
  position: relative; 
}

@media only screen and (max-width: 960px) {
.row .row .span1, 
.row .row .span2, 
.row .row .span3, 
.row .row .span4, 
.row .row .span5, 
.row .row .span6, 
.row .row .span7,
.row .row .span8, 
.row .row .span9, 
.row .row .span10, 
.row .row .span11, 
.row .row .span12, 
.row .row .span1-5, 
.row .row .span1-8 {
    width: 100% !important;
    margin-bottom: 20px;
    margin-left: 0px;
    margin-right: 0px; 
}
Brian McCutchon

Put the right side div first and make it float to the right:

<div class="row">
  <div class="span6" style="float: right;">Right side</div>
  <div class="span6">Left side</div>
</div>

This should work. Some other changes to your CSS may have to occur. I put the one CSS declaration inline for simplicity's sake. You may wish to move it to your CSS file.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

CSS: arranging floating elements

From Dev

CSS3 Animate It changes position and width properties for some elements on mobile devices

From Java

Transition width when element changes width CSS

From Dev

CSS Flex changes order positioning of text elements

From Dev

CSS Flex changes order positioning of text elements

From Dev

c++ - Arranging vector elements in a specific order

From Dev

c++ - Arranging vector elements in a specific order

From Dev

CSS - 4 <td>'s to 2 <td>'s when screen size changes

From Dev

Is there a event invoked when a block's width changes?

From Dev

Change order of flex items when flex box width changes

From Dev

Layout strategies for arranging various interface elements on Android Screen

From Dev

Why the order of elements in HashSet's keySet changes from run to run?

From Dev

HTML element moving when viewport width changes, but no change in CSS

From Dev

Panda's equivalent of R's order() for arranging dataframe columns

From Dev

How to make the width of an element the full width of the screen and not the parent's width - css

From Dev

Is there a way to re-arranging the order of blocks (flex) in Css

From Dev

CSS - making two elements overlap on small screen and taking each their own width on big screen

From Dev

Android's NumberPicker displays wrong value when screen orientation changes

From Dev

Arranging DIVs on the screen with Bootstrap

From Dev

bxSlider: changes order of li elements

From Dev

CSS ID and order of properties

From Dev

CSS properties not loading in order

From Dev

Arranging by Alphabetical Order

From Dev

arranging numbers in ascending order

From Dev

CSS set element width by screen width

From Dev

Arranging elements of a list of tuples

From Dev

React Native : Arranging elements

From Dev

arranging array elements in a group

From Dev

CSS width:100% not fitting the screen

Related Related

  1. 1

    CSS: arranging floating elements

  2. 2

    CSS3 Animate It changes position and width properties for some elements on mobile devices

  3. 3

    Transition width when element changes width CSS

  4. 4

    CSS Flex changes order positioning of text elements

  5. 5

    CSS Flex changes order positioning of text elements

  6. 6

    c++ - Arranging vector elements in a specific order

  7. 7

    c++ - Arranging vector elements in a specific order

  8. 8

    CSS - 4 <td>'s to 2 <td>'s when screen size changes

  9. 9

    Is there a event invoked when a block's width changes?

  10. 10

    Change order of flex items when flex box width changes

  11. 11

    Layout strategies for arranging various interface elements on Android Screen

  12. 12

    Why the order of elements in HashSet's keySet changes from run to run?

  13. 13

    HTML element moving when viewport width changes, but no change in CSS

  14. 14

    Panda's equivalent of R's order() for arranging dataframe columns

  15. 15

    How to make the width of an element the full width of the screen and not the parent's width - css

  16. 16

    Is there a way to re-arranging the order of blocks (flex) in Css

  17. 17

    CSS - making two elements overlap on small screen and taking each their own width on big screen

  18. 18

    Android's NumberPicker displays wrong value when screen orientation changes

  19. 19

    Arranging DIVs on the screen with Bootstrap

  20. 20

    bxSlider: changes order of li elements

  21. 21

    CSS ID and order of properties

  22. 22

    CSS properties not loading in order

  23. 23

    Arranging by Alphabetical Order

  24. 24

    arranging numbers in ascending order

  25. 25

    CSS set element width by screen width

  26. 26

    Arranging elements of a list of tuples

  27. 27

    React Native : Arranging elements

  28. 28

    arranging array elements in a group

  29. 29

    CSS width:100% not fitting the screen

HotTag

Archive