0

I'm working on a mini web project with Symfony framework and i have encountred a small problem with the CSS, when i try to make the web page responsive using the @media it doesn't work, here's the html.twig file and the css script:

<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1" name="viewport">
    <title>LIP</title>
</head>
<body>
    {% block stylesheets %}
    <link href="https://cdnjs.cloudflare.com/ajaxcss/font-awesome.min.css" rel="stylesheet">
    <link href="{{asset('css/signInUp.css')}}" rel="stylesheet">
    <link href="{{asset('css/Homestyle.css')}}" rel="stylesheet">{% endblock %}
    <link href="{{asset(" rel="icon" type="image/x-icon">
    <div class="section1">
        <div class="description">
            <img class="eiffel-icon" src="{{asset("><br>
            <h1 data-text="Lost In Paris"><span>Lost In Paris</span></h1>
            <p>xd</p>
        </div>
        <div class="top-players">
            <p class="tp_t">Top Players list</p>
            <ol>
                <li style="list-style: none">{% if top_players is defined %} {% for player in top_players %}</li>
                <li>{{ player.username|e }}{% endfor %} {% endif %}</li>
            </ol>
        </div>
    </div>
    <div class="section2">
        <div class="form-group" id="#box">
            <div id="btn-box">
                <div id="btn"></div><button class="toggle-btn" onclick="sign_in()" type="button">Sign in</button> <button class="toggle-btn" onclick="sign_up()" type="button">Sign up</button>
            </div>
            <form action="{{path('login_Player')}}" class="input-group" id="sign-in" method="post" name="fff1">
                <input class="input-field" name="_username" placeholder="Saisir votre username" required="" type="text"> <input name="_csrf_token" type="hidden" value="{{ csrf_token('authenticate') }}"> <input name="_target_path" required="" type="hidden" value="{{path('redirect_player')}}"><br>
                <input class="input-field" name="_password" placeholder="Saisir votre mot de passe" required="" type="password"><br>
                <span class="error" style="color: red"></span> <input class="submit-btn" name="B1" type="submit" value="Se connecter"> {% if error is defined %}
                <div class="alert alert-danger">
                    {{ error.messageKey|trans(error.messageData, 'security') }}
                </div>{% endif %}
            </form>
            <form action="{{path('create_Player')}}" class="input-group" id="sign-up" method="post" name="fff2" onsubmit="return signupValid()">
                <input class="input-field" name="pseudo" placeholder="Saisir votre username" required="" type="text" value=""><br>
                <input class="input-field" name="mail" placeholder="Saisir votre mail" type="text"><br>
                <input class="input-field" name="pass" placeholder="Saisir votre mot de passe" required="" type="password" value=""><br>
                <input class="input-field" name="confirm_pass" placeholder="Confirmer votre mdp" required="" type="password" value=""><br>
                <p class="error" id="signup_error" style="color: red; margin: 0; padding: 0;">{% if msg is defined%} {{ msg }} {% endif %}</p><input class="submit-btn" name="B1" type="submit" value="S'inscrire">
            </form>
        </div>
    </div>
    <div class="footer">
    <p>2020 Copyright</p><a class="fa fa-facebook" href="https://"></a> <a class="fa fa-linkedin" href="https://"></a> <img class="logo" src="{{asset('Icons/logo_ensg.png')}}"></div>{% block javascripts %} 
    <script src="{{asset('js/FormValidation.js')}}">
    </script> 
    <script src="{{asset('js/toggle.js')}}">
    </script> {% if msg is defined %} 
    <script>
    sign_up()
    </script> {% endif %} {% endblock %}
</body>
</html>

and this is my CSS:

    body {
        color: #fff;
        background-color: #11181e;
        margin: 0;
    }
    .section1 {
        background-color: #11181e;
        width: 50%;
        float: left;
        height: 100vh;
        /*border-right: 1vw solid #F5E5D6; */
        /*box-sizing: border-box;*/
        margin: 0;
        padding: 0;
    }
    .section2 {
        background-color: #11181e;
        width: 50%;
        float: left;
        overflow: hidden;
        height: 100vh;
        margin: 0;
        padding: 0;
    }
    .footer {
        height: 20%;
        width: 100%;
        margin-bottom: 0px;
        padding: 0px;
    }
    @media screen and (max-device-width: 800) {
        .section1 {
            width: 100%;
            float: top;
        }
        .section2 {
            width: 100%;
            float: bottom;
        }
        #btn-box {
            width: 10%;
            height: 5%;
        }
        #btn {
            width: 5%;
            height: 5%;
        }
    }

I deleted some style from this script because i find it not related to the problem, and when i render in my browser it gives this:enter image description here I'm not expert in css but i guess the first step to make it responsive is to change the width into 100% when screen max width is 800px, but it's not working and i tried to change many stuff and the position of the script and the meta tag (like place it into the stylesheet block) but it never worked!

Thank you in advance and have a good day everyone

DarkBee
  • 13,798
  • 5
  • 41
  • 53
  • 1
    This issue has nothing to do with `twig`, also `top` and `bottom` are no valid values for the `float` attribute. You want to reset to `float: none;`. How did you test this as the viewport of your screenshot is definitely wider than 800px – DarkBee Dec 15 '20 at 14:40
  • Please go read [ask]. Instead of saying “not working” all the time, please give a _specific_ explanation of what exactly you tried, what you intended to achieve by it, and what you got instead. – CBroe Dec 15 '20 at 14:45
  • Hello, the screen shot that I added it was just to show the display on the browser, and to test if my media work or no I use the option on Firefox developer edition that enables you to change the size of the screen like on an iPhone, iPad, etc and like I said I tried to change the order of the meta viw port tag, also float: none; but nothing changes when I render and change screen size. Sorry if I wasn't clear about the issue. – maghraoui dhia Dec 15 '20 at 16:38
  • did you try to use `!important` on the style property you want to change ? – Ben.S Dec 16 '20 at 08:07
  • Does this answer your question? [What is the difference between max-device-width and max-width for mobile web?](https://stackoverflow.com/questions/6747242/what-is-the-difference-between-max-device-width-and-max-width-for-mobile-web) – DarkBee Dec 16 '20 at 08:08
  • @Ben.S no it does not solve the problem, it's like the media screen isn't working at all, I use F12 on my navigator and change the screen size I don't know if it's the right way to test it? – maghraoui dhia Dec 18 '20 at 13:56
  • Well I don't know what was wrong but I have solved the problem using Javascript. – maghraoui dhia Dec 18 '20 at 14:14
  • @maghraouidhia did you read the question i've linked? – DarkBee Dec 19 '20 at 11:16

0 Answers0