Home > front end >  How to type media query in html tag style=" "?
How to type media query in html tag style=" "?

Time:11-19

Is there any solution for this, I need to css from style tag into style="", this code below works when I open it, but when I publish it doesn't work. I'm making website in webflow so I need to put that code in HTML Embed and that's why I need to put all of that in html. I'll be grateful if someone helps me.

Code:

<style type="text/css">
        @media only screen and (max-width: 1000px) and (min-width: 600px) {
        .linkTextingInner, #linkTexting_form {
            width: 453px;
        }

        .linkTextingInput, #numberToText_linkTexting {
            width: 309px;
            padding: 0 70px;
        }

        .linkTextingButton, #sendButton_linkTexting {
            width: 124px;
            font-size: 13px;
        }
    }

    @media only screen and (max-width: 600px) and (min-width: 400px) {
        .linkTextingInner, #linkTexting_form {
            width: 360px;
            height: 55px;
        }

        .linkTextingInput, #numberToText_linkTexting {
            width: 230px;
            padding: 0 60px;
            height: 41px;
            font-size: 18px;
        }

        .linkTextingButton, #sendButton_linkTexting {
            width: 110px;
            font-size: 11px;
            height: 41px;
        }
    }

    @media only screen and (max-width: 400px) {
        .linkTextingInner, #linkTexting_form {
            width: 320px;
            height: 55px;
        }

        .linkTextingInput, #numberToText_linkTexting {
            width: 190px;
            padding: 0 40px;
            height: 41px;
            font-size: 14px;
        }

        .linkTextingButton, #sendButton_linkTexting {
            width: 110px;
            font-size: 10px;
            height: 41px;
        }
    }

    @media only screen and (max-width: 350px) {
        .linkTextingInner, #linkTexting_form {
            width: 280px;
            height: 55px;
        }

        .linkTextingInput, #numberToText_linkTexting {
            width: 160px;
            padding: 0 20px;
            height: 41px;
            font-size: 14px;
        }

        .linkTextingButton, #sendButton_linkTexting {
            width: 100px;
            font-size: 10px;
            height: 41px;
        }
    }
</style>
</head>
<body>
<div class="badgeContainer badge-2">
    <div class="linkTextingWidgetWrapper">
        <div class="linkTextingWidget">
            <div class="promptContent"></div>
            <div class="linkTextingInner" id="linkTexting_form" style="display: flex;
            flex-flow: row wrap;
            align-items: center;
            background-color: white;
            width: 533px;
            height: 65px;
            border-radius: 50px;">
                <input type="hidden" class="linkID" value="8853c16d-94ac-47d1-8e3a- 
                     c58d4e688901">
                <div class="linkTextingInputWrapper">
                    <input class="linkTextingInput linkTextingInputFlagAdjust" type="tel" 
                    id="numberToText_linkTexting"
                    style="vertical-align: middle;
                    padding: 0 100px;
                    background-color: #fff;
                    border: 0;
                    width: 369px;
                    height: 51px;
                    margin-left: 10px;
                    border-radius: 50px;
                    font-size: 25px;
                    font-family: ProximaNova;">
                </div>
                <button class="linkTextingButton localized-button localized-text 
                     text_me_a_link" 
                    type="button"
                    id="sendButton_linkTexting" style="padding: 10px 20px;
                    background-color: #355dee;
                    color: white;
                    border-radius: 50px;
                    width: 144px;
                    cursor: pointer;
                    height: 51px;
                    border: 0;
                    font-size: 16px;
                    font-family: ProximaNova;">Text me a Link</button>
                <div class="linkTextingError" id="linkTextingError" style="display:none;"> 
                   </div>
            </div>
        </div>
    </div>
</div>

CodePudding user response:

Remove the type in style tag and use this instead

<style scoped>
 @media only screen and (max-width: 1000px) and (min-width: 600px) {
        .linkTextingInner, #linkTexting_form {
            width: 453px;
        }
</style>

CodePudding user response:

You can't, but I have 2 options for you

  • Class
  • Jss

Jss: JSS is an authoring tool for CSS which allows you to use JavaScript to describe styles in a declarative, conflict-free and reusable way. It can compile in the browser, server-side or at build time in Node.

Read Docs

Norice: Your code may not work because of style inconsistencies. I mean the styles you define for Media Query load before the main styles

  • Related