Making text responsive

i am begginer so plz dont mind my silly doubts. I am trying to make my text -movies , tv shows , games responsive . what should i do? i tried media query but i think i got it wrong . Plz try to make it simple since i am just a beginner.

<!DOCTYPE html>
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Luckiest+Guy|Bangers' rel='stylesheet' type='text/css'>
<style type="text/css">
.bg {
    width: 100%;
    height: 110%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: -4000;
}
body{
font-family: 'Luckiest Guy', cursive;}
}
</style>
<style>
a:hover {color: red;}
a { text-decoration: none; color:black; }
a:visited { text-decoration: none; }
a:hover { text-decoration: none; }
a:focus { text-decoration: none; }
a:hover, a:active { text-decoration: none; }

#one {
position: fixed;
top:180px;
left:200px;
}

#two {
position: fixed;
top:180px;
left:570px;
}

#three {
position: fixed;
top:180px;
left:900px;
}

h1{font-size:70px}
</style>
</head>
<body link="black" >
<div id="one"
<font color="black"><h1><a href="movies.html"  style="text-decoration:none">MOVIES</a></h</font></div>

 <div id="two" 
<font color="white"><h1><a href="games.html"  style="text-decoration:none">GAMES</a></h1></font></div>

<div id="three"
<font color="white"><h1><a href="tvshows.html"  style="text-decoration:none">TV SHOWS</a></h1></font></div>
<div align="center"><img src="images/ball.jpg" class="bg"></div>
</body>
</html>
1 Like

I think a good article to start with would be
Media Queries: Width vs. Device Width

First, as with getting all websites to become responsive and adhere to media queries, the viewport meta tag must be placed in the <head> section of your web page. The basic standard version of this is shown below.

<meta name="viewport" content="width=device-width,initial-scale=1">

i have tried all but no luck. could you just try once if u dont mind…

I tried it, but it has a few basic problems.

One thing you can do is go to

Copy - paste your code and click “Check”

Fix what you can - rinse, repeat.

* at least fix the missing ">"s

Thanks a lot for validator. i corrected everything. Now how to resolve it.

<!DOCTYPE html>
<html>
<head>
<title>Papaya | Home</title>
<link href='https://fonts.googleapis.com/css?family=Luckiest+Guy' rel='stylesheet' type='text/css'>
<style type="text/css">
.bg {
    width: 100%;
    height: 110%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: -4000;
}
body{
font-family: 'Luckiest Guy', cursive;}

a:hover {color: red;}
a { text-decoration: none; color:black; }
a:visited { text-decoration: none; }
a:hover { text-decoration: none; }
a:focus { text-decoration: none; }
a:hover, a:active { text-decoration: none; }

#one {
position: fixed;
top:180px;
left:200px;
}

#two {
position: fixed;
top:180px;
left:570px;
}

#three {
position: fixed;
top:180px;
left:900px;
}

h1{font-size:70px}

}
</style>
</head>

<body >
<div id="one">
<h1><a href="movies.html"  style="text-decoration:none">MOVIES</a></h1></div>

 <div id="two"> 
<h1><a href="games.html"  style="text-decoration:none">GAMES</a></h1></div>

<div id="three">
<h1><a href="tvshows.html"  style="text-decoration:none">TV SHOWS</a></h1></div>

<div align="center"><img src="images/ball.jpg" class="bg" alt="LOADING.."></div>
</body>
</html>
1 Like

Welcome to the forums, @sharathnaik.

I’m sorry, but I don’t understand what you’re asking. In web design, the term “responsive” is used to refer to a layout which changes to fit a any size of viewport. I don’t understand what you mean when you ask about making text responsive.

Perhaps if you explain what you’re trying to achieve - and maybe include a sketch of the layout you’re attempting - we would be able to offer more relevant advice. Your current code seems unnecessarily messy and complicated, and there may well be a better way to achieve your aims.

when i resize my webpage i wanna my text to move . but it isnt … you can check out the code…

in my code the text movies , games , tv shows are placed horizontally . I want it to be placed vertically as the screen decreases like on a phone. And also i have reduced my code here it is.

<!DOCTYPE html>
<html>
<head>
<title>Papaya | Home</title>
<link href='https://fonts.googleapis.com/css?family=Luckiest+Guy' rel='stylesheet' type='text/css'>
<style type="text/css">
.bg {
    width: 100%;
    height: 110%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: -4000;
}
body{
font-family: 'Luckiest Guy', cursive;}

a:hover {color: red;}
a { text-decoration: none; color:black; }

#one {
position: fixed;
top:180px;
left:200px;
}

#two {
position: fixed;
top:180px;
left:570px;
}

#three {
position: fixed;
top:180px;
left:900px;
}

h1{font-size:70px}

</style>
</head>

<body >
<div id="one">
<h1><a href="movies.html">MOVIES</a></h1></div>

 <div id="two"> 
<h1><a href="games.html">GAMES</a></h1></div>

<div id="three">
<h1><a href="tvshows.html">TV SHOWS</a></h1></div>

<div align="center"><img src="images/ball.jpg" class="bg" alt="LOADING.."></div>
</body>
</html>

It won’t behave as you wish because you’ve placed each word in a <div> with a fixed position. Remove the rules you have for those three divs and replace them with display:inline-block or float:left and they’ll wrap at narrower screen widths.

Which one is better will depend on the rest of your design, which is why I asked you to show us the layout you want to achieve.

Fixed or absolute positioning are generally only required for small areas of a design (if at all) and should be used very sparingly. Don’t use them for general layout - especially if you are aiming to make a site responsive. This article explains how those properties work: http://tympanus.net/codrops/css_reference/position/

4 Likes

YEAH HERE IT IS. THIS IS HOW I WANT IT TO BE ON PC…

THIS IS HOW I WANT IT TO BE ON MOBILE DEVICE…

That doesn’t really help, because it doesn’t show what other elements you intend to include on the page, or how those elements will fit together.

Did you try the solutions I offered in my post above? (You can add padding to achieve the spacing you want between the elements.)

thats all i want in the website nothing else. i am actually very confused how to add padding … if you dont mind can you make the changes.

Are you intending these to be links to other pages? You’re not adding any text to the headings? (I’m asking, because if this is the case, there is a better way to mark up your page; <h1> tags are not appropriate if they are not the headings for actual content.

yes they will link to other page. and no they are not the heading. i just used it to make it larger than default font size 7

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Papaya | Home</title>
<link href='https://fonts.googleapis.com/css?family=Luckiest+Guy' rel='stylesheet' type='text/css'>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style type="text/css">
.bg {
    width: 100%;
    height: 110%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: -4000;
}

body{
font-family: 'Luckiest Guy', cursive;}

a:hover {color: red;}
a { text-decoration: none; color:black; }
a:visited { text-decoration: none; }
a:hover { text-decoration: none; }
a:focus { text-decoration: none; }
a:hover, a:active { text-decoration: none; }

.loading {text-align: center;}



ul {list-style-type: none;
 text-align: center;
 margin: 0;
 padding: 0;
 }

li {font-size:70px;
 display: inline-block;
 padding: 0.25em;
 margin: 0;}


@media screen and (max-width: 820px){
    ul {text-align: left;}
    li {display: block;}
    
    }

</style>

</head>

<body >
<div class="loading"><img src="images/ball.jpg" class="bg" alt="LOADING.."></div>
<ul>
<li><a href="movies.html"  style="text-decoration:none">MOVIES</a></li>
<li><a href="games.html"  style="text-decoration:none">GAMES</a></li>
<li><a href="tvshows.html"  style="text-decoration:none">TV SHOWS</a></li>
</ul>
</body>
</html>

Something like this should do what you want. You have a list of links, not headings, so mark them up as a list. Never choose an HTML element based on how you want it to appear. Choose the element which best describes the content - paragraph, heading, list etc. - and use CSS to style it as you please.

If there’s anything in there you don’t understand, please ask.

1 Like

Perfect exactly what i wanted . thanks a lot . ill keep in mind whatever u told me to do. what should i change to increase the space between the text movies , games, tv shows and i need to make it go down almost center of screen.

Ninja’d! :smiley:

This is another version:-

<!DOCTYPE html>
<html>
<head>
    <title>Papaya | Home</title>
    <meta name=viewport content="width=device-width, initial-scale=1">  <!--Important tag for responsive pages-->
    <link href='https://fonts.googleapis.com/css?family=Luckiest+Guy' rel='stylesheet' type='text/css'>
    <style>
        body{
            font-family: 'Luckiest Guy', cursive;
            background-image: url(images/ball.jpg); /* set the background image */
            background-attachment: fixed ;
            background-repeat: no-repeat;
            background-size: cover;
            background-position: center;
            margin: 0;
            padding: 0;
        }
        .wrap {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            text-align: center; /* For older browsers */
            display: flex;
            height: 100vh; /* Full page height */
            flex-flow: wrap;
            justify-content: space-around;
            align-items: center;
        }
        .wrap li {
            display: inline-block; /* For older browsers */
            padding: 0.6em;
            margin: 0;
            font-size: 4em; /* Bigger Font */
        }
        .wrap a {
            text-decoration: none;
            color:black;
        }
        .wrap a:hover {color: red;}
        </style>
    </head>
    <body >
        <ul class="wrap">
            <li><a href="movies.html">Movies</a></li>
            <li><a href="games.html">Games</a></li>
            <li><a href="tvshows.html">TV Shows</a></li>
        </ul>
    </body>
</html> 

This uses Flex box, with inline-block as a fallback for older browsers.
I also tidied up your code to remove unnecessary and obsolete parts.
There were a few things wrong:-

.bg {
    width: 100%;
    height: 110%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: -4000;
}

I guess you intended this element to be a background image. The best way to add a background image is using the background-image property, surprisingly enough.

#one {
position: fixed;
top:180px;
left:200px;
}

This is a perfect example of how you don’t make a page responsive.
By using a fixed or absolute position and setting the position in pixels (“magic numbers”), you effectively set the page in concrete. It is totally rigid, the opposite of responsive. The key is to keep everything fluid and avoid setting positions like this.

<div id="one">
<h1><a href="movies.html">MOVIES</a></h1></div>

There is no need to wrap a block element in a <div>, you can apply a class or id directly to the element: <h1 id="one">

<div align="center">

These layout attributes are obsolete, use css to do this kind of thing.
To centre a block element use margin: auto to centre inline elements use text-align: center on its parent block.

2 Likes

Thanks a lot… i had a problem with backgroung image . you made it perfect… thanks a lott!! and i will take down everthing you said.

1 Like

It is important that you study the code and try to understand how and why it works.
This is a good reference about flex which may help you understand it.
Note that this will not work in IE 9 or earlier, that is why I added display: inline-block as a back up for the old browsers.

1 Like