I just got into CSS and HTML, this is my first website I’m making and I’m having trouble positioning my text on the page. I want it to be in the middle, next to the image, but whatever I try it doesn’t let me move it any more upwards.
Here’s the CSS for the page.
here is what it looks like right now
a {
text-transform: uppercase;
display: inline-block;
padding: 5px;
margin: 35px 30px;
text-decoration: none;
}
nav {
background-color: rgba(255, 255, 255, 1);
position: relative;
width: 100%;
height: 100px
}
.navigation ul {
margin: 0;
padding: 0;
text-align: center;
}
.navigation li {
font-weight: 100;
letter-spacing: 2px;
list-style-type: none;
color: #8D7B68;
font-size: larger;
}
body {
background-color: #ffffff;
margin: 0 auto;
}
li:hover {
color: #ed2323;
}
#banner {
background-color: rgba(164, 144, 124, .8);
background-size: cover;
background-position: bottom center;
height: 500px;
width: 100%;
}
#banner .content h1 {
border: 3px solid white;
position: relative;
top: 50px;
width: 400px;
margin: 0 auto;
}
h1 {
color: white;
font-size: 42px;
font-weight: 600;
text-align: center;
padding: 10px;
letter-spacing: 1px;
}
.milk {
display: flex;
margin: 0 0 0 150px;
width: 350px;
height: 350px;
border: rgba(164, 144, 124, .9) 3px solid;
}
.milkp {
margin: 0 675px 0 675px;
text-align: center;
max-width: 400px;
}
p {
color: rgb(0, 0, 0);
font-size: 15px;
font-weight: 300;
padding: 10px;
letter-spacing: 1px;
line-height: 25px;
}
<nav class="navigation">
<ul>
<a href="./index.html">
<li>početna stranica</li>
</a>
<a href="./proizvodi.html">
<li>proizvodi</li>
</a>
<a href="./kontakt.html">
<li>kontakt</li>
</a>
</ul>
</nav>
<div id="banner">
<div class="content">
<h1>mliječna čokolada</h1>
<img src="https://i.pinimg.com/564x/47/99/71/47997186f6af47d86181766d78d55f47.jpg" alt="choco" class="milk">
<p class="milkp">
Prvi niz, upućen voljenom mladiću, bolje je uređen i sadrži nekoliko kraćih nizova koji se tiču njihova odnosa ili obrađuju pripadne ideje. Tako soneti 117 potiču mladića da nađe životnu družicu i dobije djecu; soneti 41 i 42 upozoravaju da je pjesnikova
ljubavnica zavela mladića tijekom pjesnikova izbivanja; soneti 7886 opisuju pjesnikarivala koji je očevidno pokušao pridobiti mladića za sebe; u sonetima 8790 iskazana je zabrinutost da je mladić potpuno zaboravio pjesnika
</p>
</div>
</div>
I tried moving it using margins but it won’t let me move it upwards, just down right or left.
Tried setting the positioning to be different, display to something else but it doesn’t do anything.
2
Answers
CSS grid is a great for layout. I’ve put explainers on each line of CSS to describe what it does. Here’s a good introduction on css tricks and a nice video from Kevin Powell to get you started. Good luck!
Please Try This types of code changes might be working for you.
Here is CSS
Here is HTML
This works well for you.