Materialize: Broken valign-wrapper with row class.

Created on 4 Apr 2016  路  7Comments  路  Source: Dogfalo/materialize

I'm trying to use the valign-wrapper inside a row, but for some reason, the row/column functionality becomes broken when the wrapper is introduced. Any insight?

Sample Code:

<div class="container">
    <h1>Without valign</h1><br>
    <div class="row">
        <div class="col s12 m4 l4">
            <img src="images/profile_images/face.png" class="responsive-img">
        </div>
        <div class="col s12 m8 l8 left-align ">
            <img class="valign" src="images/other_images/email_icon.png" height="30" width="30">
            <a class="blue-link-no-padding" href="mailto:[email protected]">[email protected]</a><br>
            <img class="valign" src="images/other_images/phone_icon.png" height="30" width="30">
            <a class="blue-link-no-padding" href="tel:1-888-555-1234">+1 (888) 555-1234</a>
        </div>
    </div>

    <h1>With valign</h1><br>
    <div class="row valign-wrapper">
        <div class="col s12 m4 l4 valign">
            <img src="images/profile_images/face.png" class="responsive-img">
        </div>
        <div class="col s12 m8 l8 left-align valign">
            <img class="valign" src="images/other_images/email_icon.png" height="30" width="30">
            <a class="blue-link-no-padding" href="mailto:[email protected]">[email protected]</a><br>
            <img class="valign" src="images/other_images/phone_icon.png" height="30" width="30">
            <a class="blue-link-no-padding" href="tel:1-888-555-1234">+1 (888) 555-1234</a>
        </div>
    </div>
</div>

Desktop:
screen shot 2016-04-04 at 1 04 18 pm

Mobile:
screen shot 2016-04-04 at 1 04 50 pm copy

bug css

Most helpful comment

@darckyn +1: definitely on the right track and much less verbose.

@bionetmarco: If you don't want to use Sass, you can just add a css media query at the end of your stylesheet. In your specific sample code, I found that you'll need to increase the specificity of your selector to get @darckyn's code to work https://plnkr.co/ByUOUA92GHTelskSvXcs:

@media only screen and (max-width: 600px) { .row.valign-wrapper { display: inherit; } }

All 7 comments

The same problem here...

plz help.

Here is a hacked solution that works. I duplicate the same row, but only apply the valign-wrapper and valign tags when the screen size is medium or large, and on small, I display a normal row and column grid. To achieved this, I use the helper classes "hide-on-med-and-up" and "hide-on-small-only". Dirty but effective. I don't have time to learn above flex and flex-direction. :100:

<div class="container">
    <div class="row hide-on-med-and-up">
        <div class="col s12 m4 l4">
            <img src="images/profile_images/face.png" class="responsive-img">
        </div>
        <div class="col s12 m8 l8 center-align ">
            <img class="valign" src="images/other_images/email_icon.png" height="30" width="30">
            <a class="blue-link-no-padding" href="mailto:[email protected]">[email protected]</a><br>
            <img class="valign" src="images/other_images/phone_icon.png" height="30" width="30">
            <a class="blue-link-no-padding" href="tel:1-888-555-1234">+1 (888) 555-1234</a>
        </div>
    </div>

    <div class="row hide-on-small-only valign-wrapper">
        <div class="col s12 m4 l4 valign">
            <img src="images/profile_images/face.png" class="responsive-img">
        </div>
        <div class="col s12 m8 l8 left-align valign">
            <img class="valign" src="images/other_images/email_icon.png" height="30" width="30">
            <a class="blue-link-no-padding" href="mailto:[email protected]">[email protected]</a><br>
            <img class="valign" src="images/other_images/phone_icon.png" height="30" width="30">
            <a class="blue-link-no-padding" href="tel:1-888-555-1234">+1 (888) 555-1234</a>
        </div>
    </div>
</div>

I used this css code and it helped me:

@media #{$small-and-down} {
.valign-wrapper{
display: inherit;
}
}

@darckyn +1: definitely on the right track and much less verbose.

@bionetmarco: If you don't want to use Sass, you can just add a css media query at the end of your stylesheet. In your specific sample code, I found that you'll need to increase the specificity of your selector to get @darckyn's code to work https://plnkr.co/ByUOUA92GHTelskSvXcs:

@media only screen and (max-width: 600px) { .row.valign-wrapper { display: inherit; } }

I put in my 2-cents about this on the other issue thread (#3361), including a possible workaround with position:absolute.

https://github.com/Dogfalo/materialize/issues/3361#issuecomment-333342892

valign uses flexbox to achieve vertical centering which conflicts with the grid system, so in general it should be used in localized places

I have been looking in this discussion and I learn something which helped me solve a problem in may development, tks for all.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cope picture cope  路  3Comments

Robouste picture Robouste  路  3Comments

serkandurusoy picture serkandurusoy  路  3Comments

bradley-varol picture bradley-varol  路  3Comments

djensen47 picture djensen47  路  3Comments