I have recently started using html in order to create a website for my project. I have planned on making this website that contains the intro page, that has a button, revealing further contents. This is my current html code:
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #24576c;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
#box {
width: 80%;
background-color: #D5C6EE;
border: 1px solid #ccc;
border-radius: 10px;
padding: 20px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
justify-content: space-between;
height: auto;
}
#title {
text-align: center;
margin-bottom: 10px;
font-weight: bold;
}
#underline {
border: none;
height: 2px;
background-color: #131E62;
width: 100%;
margin-bottom: 20px;
}
#content {
font-size: 20px;
text-align: justify;
line-height: 1.6;
flex-grow: 1;
}
.button {
display: flex;
justify-content: center;
margin-top: 20px;
}
#know-more-button {
text-decoration: none;
background-color: #AABFEF;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
#know-more-button:hover {
background-color: #0056b3;
}
body {
background-image: url(".jpg!d");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
height: 100vh;
margin: 0;
}
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chem project</title>
<link rel="stylesheet" href="style.css">
<link href=":wght@400;700&display=swap" rel="stylesheet">
</head>
<body>
<div id="box">
<h1 id="title">Brief Introduction</h1>
<hr id="underline">
<div id="content">
<p>content</p>
</div>
</div>
<br>
<div id="button-container" class="button">
<a id="know-more-button" href="secondpage.html">Know More</a>
</div>
</body>
</html>
I have recently started using html in order to create a website for my project. I have planned on making this website that contains the intro page, that has a button, revealing further contents. This is my current html code:
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #24576c;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
#box {
width: 80%;
background-color: #D5C6EE;
border: 1px solid #ccc;
border-radius: 10px;
padding: 20px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
justify-content: space-between;
height: auto;
}
#title {
text-align: center;
margin-bottom: 10px;
font-weight: bold;
}
#underline {
border: none;
height: 2px;
background-color: #131E62;
width: 100%;
margin-bottom: 20px;
}
#content {
font-size: 20px;
text-align: justify;
line-height: 1.6;
flex-grow: 1;
}
.button {
display: flex;
justify-content: center;
margin-top: 20px;
}
#know-more-button {
text-decoration: none;
background-color: #AABFEF;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
#know-more-button:hover {
background-color: #0056b3;
}
body {
background-image: url("https://c.wallhere/photos/c6/5c/chemistry_science_laboratories-1697571.jpg!d");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
height: 100vh;
margin: 0;
}
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chem project</title>
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis/css2?family=Montserrat:wght@400;700&display=swap" rel="stylesheet">
</head>
<body>
<div id="box">
<h1 id="title">Brief Introduction</h1>
<hr id="underline">
<div id="content">
<p>content</p>
</div>
</div>
<br>
<div id="button-container" class="button">
<a id="know-more-button" href="secondpage.html">Know More</a>
</div>
</body>
</html>
Everything turns out to be good, except for the "know more button" that I expected to be in the bottom of the box. (shown below)
I would like to ask for your help in order to make the button appear at the right place. :)
Share Improve this question edited Nov 17, 2024 at 13:49 Rob 15.2k30 gold badges48 silver badges73 bronze badges asked Nov 17, 2024 at 3:42 Srijan SinghSrijan Singh 91 bronze badge 1- If the answer helped solve your problem you can mark it as solved using the grey tick on the left of the answer. – stickynotememo Commented Nov 24, 2024 at 23:35
1 Answer
Reset to default 1The div
of your button is not nested inside the box div. This means it will appear outside of the box.
It should look something like this:
<div id="box">
<h1 id="title">Brief Introduction</h1>
<hr id="underline">
<div id="content">
<p>content</p>
</div>
<br>
<div id="button-container" class="button">
<a id="know-more-button" href="secondpage.html">Know More</a>
</div>
</div>