How to place image and text next to Flexbox?

Asked

Viewed 1,059 times

0

Eae guys I’m having difficulty positioning the image and the text BESIDE the image. I’ve tried table but it is not responsive. I tried ul/li and I can’t position. I’m using Flexbox. Any suggestions?.

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="UTF-8">
    	<meta name="viewport" content="width=device-width, initial-scale=1"/>
    	<title>About Us</title>
    	<link rel="stylesheet" type="text/css" href="css/style3.css">
    	<link rel="shortcut icon" href="images/logo.png">
    	<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
    	<link href="https://fonts.googleapis.com/css?family=Arimo" rel="stylesheet">
       <link href="https://fonts.googleapis.com/css?family=Bree+Serif" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css?family=Raleway:400,700" rel="stylesheet">
    </head>
        
    <body>
        <section class="bg">
            <div class="auutor">
                <h1>The Author</h1>
            </div>
            <ul class="fuckk">
                <li>
                    <img src="images/1313.png"/>
                    <h1>Roft Salem Throme</h1>
                    <p>But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain.</p>
                </li>
            </ul>
        </section>
    </body>
</html>

  • Is it possible to make it clearer that it should be next to it ? In your example there are 4 labels with content, h1, p, h1, img. Which ones should stand next to which?

1 answer

1

You can use the property display : flex in his li involving the title h1 and the paragraph p in a div, how so:

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="UTF-8">
    	<meta name="viewport" content="width=device-width, initial-scale=1"/>
    	<title>About Us</title>
    	<link rel="stylesheet" type="text/css" href="css/style3.css">
    	<link rel="shortcut icon" href="images/logo.png">
    	<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
    	<link href="https://fonts.googleapis.com/css?family=Arimo" rel="stylesheet">
       <link href="https://fonts.googleapis.com/css?family=Bree+Serif" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css?family=Raleway:400,700" rel="stylesheet">

        <style type="text/css">
        	li {
        		list-style-type: none;
        	}

            .conteudo {
                display: flex;
            }

            h1 {
            	text-align: center;
            }

            li img {
                width : 20%;
                height: 20%;
                vertical-align: middle;
            }
        </style>
    </head>
        
    <body>
        <section class="bg">
            <div class="auutor">
                <h1>The Author</h1>
            </div>
            <ul class="fuckk">
                <li>
                	<h1>Roft Salem Throme</h1>
                    <div class="conteudo">
                    	<img src="https://www.freeiconspng.com/uploads/help-icon-26.png"/>
                        <p>But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain.</p>
                    </div>
                </li>
            </ul>
        </section>
    </body>
</html>

  • It didn’t work, my H1 is on the side of the image I can’t center it. p the same thing is on top and n I can leave it in the middle too. Sad :(

  • I edited the code to get H1 up and centered, take a look!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.