Web Global Net Web Application & Web Development Project Center

Technical Issues => CSS Related => Topic started by: admin on February 21, 2019, 05:14: PM



Title: Hiding and element on a page based on screen size
Post by: admin on February 21, 2019, 05:14: PM
I wanted to hide a uploaded graphic header on a smartphone because it took up too much space, yet I wanted the uploaded graphic header to show on larger screens. Although I saw a lot complicated ways to do it , this method below was by far the simplest.

On the page I added this style into the head area.

 <style>
    @media all and (max-width: 479px) {
    .header_upload {display:none;}
}</style>


Then what ever I wanted to hide I wrapped it in a Div tag with the class of the element name (in red) :

<div class="header_upload">
         <?php
// Show IF Conditional region2
if (@$row_rsgroup_prefences_session['group_pref_website_header'] != "") {
?>
              <?php include("Main_File_1/inc_pages/header_logo.php"); ?><?php }
// endif Conditional region2
?>
         <?php
// Show IF Conditional region3
if (@$row_rsgroup_preferences_url['group_pref_website_header'] != "") {
?>
              <?php include("Main_File_1/inc_pages/header_logo.php"); ?>
              <?php }
// endif Conditional region3
?>
      </div>  

You can add as many <Div class"Element_Name"> </Div> wrappers on a page as you need too it seems.

just add this to the Media style for each element you want to hide.
 .Element_Name {display:none;}