want text overlay to be responsive with its background












-1















I have a background that I want to put text over it. It is somewhat responsive but if I view it on a smaller screen the text spills over the image. I want the size of the text to adjust to the shrinking size.



HTML:



<div className="row">
<div className="col-md-12 text-overlay-container">
<span className="text-overlay">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</span>
<img className="d-block w-100 gradient-img" src="../images/slanted-gradient-background.png" alt="" />
</div>
</div>


CSS:



.text-overlay-container {
position: relative;
text-align: center;
color: white;
}

.text-overlay {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 70%;
}









share|improve this question

























  • Maybe, that you are looking for is the Responsive Media Queries in CSS

    – R. García
    Nov 14 '18 at 20:34











  • don't keep the react code while creating a snippet

    – Temani Afif
    Nov 14 '18 at 20:46











  • Thank you! That was exactly what I was looking for.

    – Stacy Areas
    Nov 14 '18 at 20:48
















-1















I have a background that I want to put text over it. It is somewhat responsive but if I view it on a smaller screen the text spills over the image. I want the size of the text to adjust to the shrinking size.



HTML:



<div className="row">
<div className="col-md-12 text-overlay-container">
<span className="text-overlay">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</span>
<img className="d-block w-100 gradient-img" src="../images/slanted-gradient-background.png" alt="" />
</div>
</div>


CSS:



.text-overlay-container {
position: relative;
text-align: center;
color: white;
}

.text-overlay {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 70%;
}









share|improve this question

























  • Maybe, that you are looking for is the Responsive Media Queries in CSS

    – R. García
    Nov 14 '18 at 20:34











  • don't keep the react code while creating a snippet

    – Temani Afif
    Nov 14 '18 at 20:46











  • Thank you! That was exactly what I was looking for.

    – Stacy Areas
    Nov 14 '18 at 20:48














-1












-1








-1








I have a background that I want to put text over it. It is somewhat responsive but if I view it on a smaller screen the text spills over the image. I want the size of the text to adjust to the shrinking size.



HTML:



<div className="row">
<div className="col-md-12 text-overlay-container">
<span className="text-overlay">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</span>
<img className="d-block w-100 gradient-img" src="../images/slanted-gradient-background.png" alt="" />
</div>
</div>


CSS:



.text-overlay-container {
position: relative;
text-align: center;
color: white;
}

.text-overlay {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 70%;
}









share|improve this question
















I have a background that I want to put text over it. It is somewhat responsive but if I view it on a smaller screen the text spills over the image. I want the size of the text to adjust to the shrinking size.



HTML:



<div className="row">
<div className="col-md-12 text-overlay-container">
<span className="text-overlay">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</span>
<img className="d-block w-100 gradient-img" src="../images/slanted-gradient-background.png" alt="" />
</div>
</div>


CSS:



.text-overlay-container {
position: relative;
text-align: center;
color: white;
}

.text-overlay {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 70%;
}






html css twitter-bootstrap






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 20:46









Temani Afif

74.2k94386




74.2k94386










asked Nov 14 '18 at 20:27









Stacy AreasStacy Areas

498




498













  • Maybe, that you are looking for is the Responsive Media Queries in CSS

    – R. García
    Nov 14 '18 at 20:34











  • don't keep the react code while creating a snippet

    – Temani Afif
    Nov 14 '18 at 20:46











  • Thank you! That was exactly what I was looking for.

    – Stacy Areas
    Nov 14 '18 at 20:48



















  • Maybe, that you are looking for is the Responsive Media Queries in CSS

    – R. García
    Nov 14 '18 at 20:34











  • don't keep the react code while creating a snippet

    – Temani Afif
    Nov 14 '18 at 20:46











  • Thank you! That was exactly what I was looking for.

    – Stacy Areas
    Nov 14 '18 at 20:48

















Maybe, that you are looking for is the Responsive Media Queries in CSS

– R. García
Nov 14 '18 at 20:34





Maybe, that you are looking for is the Responsive Media Queries in CSS

– R. García
Nov 14 '18 at 20:34













don't keep the react code while creating a snippet

– Temani Afif
Nov 14 '18 at 20:46





don't keep the react code while creating a snippet

– Temani Afif
Nov 14 '18 at 20:46













Thank you! That was exactly what I was looking for.

– Stacy Areas
Nov 14 '18 at 20:48





Thank you! That was exactly what I was looking for.

– Stacy Areas
Nov 14 '18 at 20:48












3 Answers
3






active

oldest

votes


















0














Your answer is the Responsive Web Design Media Queries using the Typical Device Breakpoints:



/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {...}

/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {...}

/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {...}

/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {...}

/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {...}




This example will allow you to re-scale your web-content depends of the screen of the device that runs the web page.




Also take a look to this specific
Example







share|improve this answer































    0














    Use the viewport width vw measurement to dynamically adjust the font size based on the viewport. Check out this very basic CodePen example.






    .text-overlay-container {
    position: relative;
    text-align: center;
    color: white;
    }

    .text-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    font-size: 3.5vw;
    }

    <div className="row">
    <div className="col-md-12 text-overlay-container">
    <span className="text-overlay">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>
    <img className="d-block w-100 gradient-img" src="../images/slanted-gradient-background.png" alt="" />
    </div>
    </div>








    share|improve this answer































      0














      You can either use media queries to reduce the size at certain breakpoints, ex:



      @media only screen and (max-width: 767px) {
      .text-overlay {
      font-size: 75%;
      }
      }


      Or you can use calc and vw units to scale the text somewhat with the screen width, which will need some tweaking to get right, ex (simplistic example):



      .text-overlay {
      font-size: calc(16px + 2vw);
      }


      That means a minimum font size of 16px, plus 2vw units.



      More info on this technique (including more accurate and complex examples):
      https://css-tricks.com/snippets/css/fluid-typography/






      share|improve this answer























        Your Answer






        StackExchange.ifUsing("editor", function () {
        StackExchange.using("externalEditor", function () {
        StackExchange.using("snippets", function () {
        StackExchange.snippets.init();
        });
        });
        }, "code-snippets");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "1"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308259%2fwant-text-overlay-to-be-responsive-with-its-background%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        0














        Your answer is the Responsive Web Design Media Queries using the Typical Device Breakpoints:



        /* Extra small devices (phones, 600px and down) */
        @media only screen and (max-width: 600px) {...}

        /* Small devices (portrait tablets and large phones, 600px and up) */
        @media only screen and (min-width: 600px) {...}

        /* Medium devices (landscape tablets, 768px and up) */
        @media only screen and (min-width: 768px) {...}

        /* Large devices (laptops/desktops, 992px and up) */
        @media only screen and (min-width: 992px) {...}

        /* Extra large devices (large laptops and desktops, 1200px and up) */
        @media only screen and (min-width: 1200px) {...}




        This example will allow you to re-scale your web-content depends of the screen of the device that runs the web page.




        Also take a look to this specific
        Example







        share|improve this answer




























          0














          Your answer is the Responsive Web Design Media Queries using the Typical Device Breakpoints:



          /* Extra small devices (phones, 600px and down) */
          @media only screen and (max-width: 600px) {...}

          /* Small devices (portrait tablets and large phones, 600px and up) */
          @media only screen and (min-width: 600px) {...}

          /* Medium devices (landscape tablets, 768px and up) */
          @media only screen and (min-width: 768px) {...}

          /* Large devices (laptops/desktops, 992px and up) */
          @media only screen and (min-width: 992px) {...}

          /* Extra large devices (large laptops and desktops, 1200px and up) */
          @media only screen and (min-width: 1200px) {...}




          This example will allow you to re-scale your web-content depends of the screen of the device that runs the web page.




          Also take a look to this specific
          Example







          share|improve this answer


























            0












            0








            0







            Your answer is the Responsive Web Design Media Queries using the Typical Device Breakpoints:



            /* Extra small devices (phones, 600px and down) */
            @media only screen and (max-width: 600px) {...}

            /* Small devices (portrait tablets and large phones, 600px and up) */
            @media only screen and (min-width: 600px) {...}

            /* Medium devices (landscape tablets, 768px and up) */
            @media only screen and (min-width: 768px) {...}

            /* Large devices (laptops/desktops, 992px and up) */
            @media only screen and (min-width: 992px) {...}

            /* Extra large devices (large laptops and desktops, 1200px and up) */
            @media only screen and (min-width: 1200px) {...}




            This example will allow you to re-scale your web-content depends of the screen of the device that runs the web page.




            Also take a look to this specific
            Example







            share|improve this answer













            Your answer is the Responsive Web Design Media Queries using the Typical Device Breakpoints:



            /* Extra small devices (phones, 600px and down) */
            @media only screen and (max-width: 600px) {...}

            /* Small devices (portrait tablets and large phones, 600px and up) */
            @media only screen and (min-width: 600px) {...}

            /* Medium devices (landscape tablets, 768px and up) */
            @media only screen and (min-width: 768px) {...}

            /* Large devices (laptops/desktops, 992px and up) */
            @media only screen and (min-width: 992px) {...}

            /* Extra large devices (large laptops and desktops, 1200px and up) */
            @media only screen and (min-width: 1200px) {...}




            This example will allow you to re-scale your web-content depends of the screen of the device that runs the web page.




            Also take a look to this specific
            Example








            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 14 '18 at 20:41









            R. GarcíaR. García

            523313




            523313

























                0














                Use the viewport width vw measurement to dynamically adjust the font size based on the viewport. Check out this very basic CodePen example.






                .text-overlay-container {
                position: relative;
                text-align: center;
                color: white;
                }

                .text-overlay {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                width: 70%;
                font-size: 3.5vw;
                }

                <div className="row">
                <div className="col-md-12 text-overlay-container">
                <span className="text-overlay">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>
                <img className="d-block w-100 gradient-img" src="../images/slanted-gradient-background.png" alt="" />
                </div>
                </div>








                share|improve this answer




























                  0














                  Use the viewport width vw measurement to dynamically adjust the font size based on the viewport. Check out this very basic CodePen example.






                  .text-overlay-container {
                  position: relative;
                  text-align: center;
                  color: white;
                  }

                  .text-overlay {
                  position: absolute;
                  top: 50%;
                  left: 50%;
                  transform: translate(-50%, -50%);
                  width: 70%;
                  font-size: 3.5vw;
                  }

                  <div className="row">
                  <div className="col-md-12 text-overlay-container">
                  <span className="text-overlay">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>
                  <img className="d-block w-100 gradient-img" src="../images/slanted-gradient-background.png" alt="" />
                  </div>
                  </div>








                  share|improve this answer


























                    0












                    0








                    0







                    Use the viewport width vw measurement to dynamically adjust the font size based on the viewport. Check out this very basic CodePen example.






                    .text-overlay-container {
                    position: relative;
                    text-align: center;
                    color: white;
                    }

                    .text-overlay {
                    position: absolute;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                    width: 70%;
                    font-size: 3.5vw;
                    }

                    <div className="row">
                    <div className="col-md-12 text-overlay-container">
                    <span className="text-overlay">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>
                    <img className="d-block w-100 gradient-img" src="../images/slanted-gradient-background.png" alt="" />
                    </div>
                    </div>








                    share|improve this answer













                    Use the viewport width vw measurement to dynamically adjust the font size based on the viewport. Check out this very basic CodePen example.






                    .text-overlay-container {
                    position: relative;
                    text-align: center;
                    color: white;
                    }

                    .text-overlay {
                    position: absolute;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                    width: 70%;
                    font-size: 3.5vw;
                    }

                    <div className="row">
                    <div className="col-md-12 text-overlay-container">
                    <span className="text-overlay">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>
                    <img className="d-block w-100 gradient-img" src="../images/slanted-gradient-background.png" alt="" />
                    </div>
                    </div>








                    .text-overlay-container {
                    position: relative;
                    text-align: center;
                    color: white;
                    }

                    .text-overlay {
                    position: absolute;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                    width: 70%;
                    font-size: 3.5vw;
                    }

                    <div className="row">
                    <div className="col-md-12 text-overlay-container">
                    <span className="text-overlay">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>
                    <img className="d-block w-100 gradient-img" src="../images/slanted-gradient-background.png" alt="" />
                    </div>
                    </div>





                    .text-overlay-container {
                    position: relative;
                    text-align: center;
                    color: white;
                    }

                    .text-overlay {
                    position: absolute;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                    width: 70%;
                    font-size: 3.5vw;
                    }

                    <div className="row">
                    <div className="col-md-12 text-overlay-container">
                    <span className="text-overlay">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>
                    <img className="d-block w-100 gradient-img" src="../images/slanted-gradient-background.png" alt="" />
                    </div>
                    </div>






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 14 '18 at 20:35









                    PeterPeter

                    477216




                    477216























                        0














                        You can either use media queries to reduce the size at certain breakpoints, ex:



                        @media only screen and (max-width: 767px) {
                        .text-overlay {
                        font-size: 75%;
                        }
                        }


                        Or you can use calc and vw units to scale the text somewhat with the screen width, which will need some tweaking to get right, ex (simplistic example):



                        .text-overlay {
                        font-size: calc(16px + 2vw);
                        }


                        That means a minimum font size of 16px, plus 2vw units.



                        More info on this technique (including more accurate and complex examples):
                        https://css-tricks.com/snippets/css/fluid-typography/






                        share|improve this answer




























                          0














                          You can either use media queries to reduce the size at certain breakpoints, ex:



                          @media only screen and (max-width: 767px) {
                          .text-overlay {
                          font-size: 75%;
                          }
                          }


                          Or you can use calc and vw units to scale the text somewhat with the screen width, which will need some tweaking to get right, ex (simplistic example):



                          .text-overlay {
                          font-size: calc(16px + 2vw);
                          }


                          That means a minimum font size of 16px, plus 2vw units.



                          More info on this technique (including more accurate and complex examples):
                          https://css-tricks.com/snippets/css/fluid-typography/






                          share|improve this answer


























                            0












                            0








                            0







                            You can either use media queries to reduce the size at certain breakpoints, ex:



                            @media only screen and (max-width: 767px) {
                            .text-overlay {
                            font-size: 75%;
                            }
                            }


                            Or you can use calc and vw units to scale the text somewhat with the screen width, which will need some tweaking to get right, ex (simplistic example):



                            .text-overlay {
                            font-size: calc(16px + 2vw);
                            }


                            That means a minimum font size of 16px, plus 2vw units.



                            More info on this technique (including more accurate and complex examples):
                            https://css-tricks.com/snippets/css/fluid-typography/






                            share|improve this answer













                            You can either use media queries to reduce the size at certain breakpoints, ex:



                            @media only screen and (max-width: 767px) {
                            .text-overlay {
                            font-size: 75%;
                            }
                            }


                            Or you can use calc and vw units to scale the text somewhat with the screen width, which will need some tweaking to get right, ex (simplistic example):



                            .text-overlay {
                            font-size: calc(16px + 2vw);
                            }


                            That means a minimum font size of 16px, plus 2vw units.



                            More info on this technique (including more accurate and complex examples):
                            https://css-tricks.com/snippets/css/fluid-typography/







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 14 '18 at 20:39









                            emmzeeemmzee

                            340210




                            340210






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308259%2fwant-text-overlay-to-be-responsive-with-its-background%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Bressuire

                                Vorschmack

                                Quarantine