Why does the border not line up with content? - html

I'm new to CSS/HTML, and I can't figure out why the border does not line up with the content/image. The bottom border is offset by a few pixels, leaving a gap between the edge of the picture and the actual border. Does anyone know how to fix this?
/* Body */
body {
background-image: url("https://i.pinimg.com/originals/a4/bf/58/a4bf58276d674626f52092e2194f79d8.jpg");
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
background-color: black;
}
/* Title */
h1 {
background-color: rgba(255, 255, 255, 0.5);
height: auto;
margin: 0% 1% 2% 1%;
padding: 0% 10% 0% 10%;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
font-size: 225%;
color: white;
text-align: center;
line-height: 150%;
text-shadow: 2px 2px rgb(253, 0, 232);
}
/* Left Body Items */
#left {
float: left;
width: 67%;
margin-right: 2%;
margin-left: 1%;
}
/* Presentation Text */
#intro_text {
background-color: rgba(255, 255, 255, 0.80);
padding: 2%;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
color: black;
text-align: justify;
line-height: 130%;
}
/* Skyline Photo */
#photo {
border-width: 3%;
border-style: solid;
border-color: rgb(253, 0, 232);
}
/* Bar Menu */
/* Right Body Items */
#right {
float: right;
width: 30%;
}
/* Booking Button */
#button {
/* Booking Button */
background-color: black;
margin-bottom: 2%;
border-style: solid;
border-width: 2%;
border-color: white rgb(253, 0, 232) rgb(253, 0, 232) white;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
color: white;
text-align: center;
text-decoration: underline;
font-weight: bold;
font-style: italic;
text-shadow: 1px 1px rgb(253, 0, 232);
}
/* Informations */
#infos {
/* General Information */
background-color: rgba(253, 0, 232, 0.6);
padding: 1% 3% 3% 3%;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
color: white;
}
.bold_underlined {
/* Information Headings */
font-weight: bold;
text-decoration: underline;
}
#metro {
/* Metro Information */
color: gold
}
<h1>Rooftop Bar, in the center of NYC</h1>
<!--Title-->
<div id="blocks">
<!--Body-->
<div id="left">
<!--Left Body Items-->
<div id="intro_text">
<!--Presentation Text-->
The 23rd Street Rooftop Bar welcomes you every day for a unique New York experience. In the iconic neighborhood of Chelsea, the bar presents a magnificent view on the New York skyline at night. With DJs from all around the world, the Rooftop Bar offers
a vast assortment of music to suit all tastes: from Disco to Hip-Hop, passing by Pop and Electro. The perfect party for you!
</div>
<br>
<div id="photo">
<!--Skyline Photo-->
<img src="https://www.thepresslounge.com/wp-content/uploads/2014/06/Press_Lounge_0028-HDR-2-Edit-1600x900.jpg" alt="View from the rooftop." width="100%">
</div>
<br><br>
<div id="menu">
<!--Bar Menu-->
Menu
</div>
</div>
<div id="right">
<!--Right Body Items-->
<div id="button">
<!--Booking Button-->
<p>
Book now!
</p>
</div>
<div id="infos">
<!--Informations-->
<p>
<!--Age & ID-->
<em>All guests must be aged 21 or older.<br>
A valid ID is required.<br></em>
<br>
<!--Opening Hours-->
<span class="bold_underlined">Opening Hours:</span><br> Mon: 5pm-1am<br> Tue: 5pm-1am<br> Wed: 5pm-1am<br> Thu: 5pm-1am<br> Fri: 5pm-2am<br> Sat: 2pm-3am <br> Sun: 2pm-8pm<br>
<br>
<!--Contact Info-->
<span class="bold_underlined">Contact Info:</span><br>
<em>📞 +1 917-722-2439</em><br> 📧
<em>&nbsp info#rtnyc.com </em><br>
<br>
<!--Location-->
<span class="bold_underlined">Access:</span><br>
<span id="metro"><strong>â“‚</strong> 23rd Street</span><br>
<em>119 W 23rd St, New York, NY 10011, USA</em>
</p>
<!--Embeded Map-->
<iframe src="https://snazzymaps.com/embed/187161" width="100%" height="250px" style="border:none;" title="Google Map of Rooftop Party location"></iframe>
</div>
</div>
</div>
https://jsfiddle.net/wp9cn3kt/1/

Just give display: block; property to your image and that's it.
/* Body */
body {
background-image: url("https://i.pinimg.com/originals/a4/bf/58/a4bf58276d674626f52092e2194f79d8.jpg");
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
background-color: black;
}
/* Title */
h1 {
background-color: rgba(255, 255, 255, 0.5);
height: auto;
margin: 0% 1% 2% 1%;
padding: 0% 10% 0% 10%;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
font-size: 225%;
color: white;
text-align: center;
line-height: 150%;
text-shadow: 2px 2px rgb(253, 0, 232);
}
/* Left Body Items */
#left {
float: left;
width: 67%;
margin-right: 2%;
margin-left: 1%;
}
/* Presentation Text */
#intro_text {
background-color: rgba(255, 255, 255, 0.80);
padding: 2%;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
color: black;
text-align: justify;
line-height: 130%;
}
/* Skyline Photo */
#photo {
border-width: 3%;
border-style: solid;
border-color: rgb(253, 0, 232);
}
/* Bar Menu */
/* Right Body Items */
#right {
float: right;
width: 30%;
}
/* Booking Button */
#button {
/* Booking Button */
background-color: black;
margin-bottom: 2%;
border-style: solid;
border-width: 2%;
border-color: white rgb(253, 0, 232) rgb(253, 0, 232) white;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
color: white;
text-align: center;
text-decoration: underline;
font-weight: bold;
font-style: italic;
text-shadow: 1px 1px rgb(253, 0, 232);
}
/* Informations */
#infos {
/* General Information */
background-color: rgba(253, 0, 232, 0.6);
padding: 1% 3% 3% 3%;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
color: white;
}
.bold_underlined {
/* Information Headings */
font-weight: bold;
text-decoration: underline;
}
#metro {
/* Metro Information */
color: gold
}
<h1>Rooftop Bar, in the center of NYC</h1>
<!--Title-->
<div id="blocks">
<!--Body-->
<div id="left">
<!--Left Body Items-->
<div id="intro_text">
<!--Presentation Text-->
The 23rd Street Rooftop Bar welcomes you every day for a unique New York experience. In the iconic neighborhood of Chelsea, the bar presents a magnificent view on the New York skyline at night. With DJs from all around the world, the Rooftop Bar offers
a vast assortment of music to suit all tastes: from Disco to Hip-Hop, passing by Pop and Electro. The perfect party for you!
</div>
<br>
<div id="photo">
<!--Skyline Photo-->
<img src="https://www.thepresslounge.com/wp-content/uploads/2014/06/Press_Lounge_0028-HDR-2-Edit-1600x900.jpg" style="display: block;" alt="View from the rooftop." width="100%">
</div>
<br><br>
<div id="menu">
<!--Bar Menu-->
Menu
</div>
</div>
<div id="right">
<!--Right Body Items-->
<div id="button">
<!--Booking Button-->
<p>
Book now!
</p>
</div>
<div id="infos">
<!--Informations-->
<p>
<!--Age & ID-->
<em>All guests must be aged 21 or older.<br>
A valid ID is required.<br></em>
<br>
<!--Opening Hours-->
<span class="bold_underlined">Opening Hours:</span><br> Mon: 5pm-1am<br> Tue: 5pm-1am<br> Wed: 5pm-1am<br> Thu: 5pm-1am<br> Fri: 5pm-2am<br> Sat: 2pm-3am <br> Sun: 2pm-8pm<br>
<br>
<!--Contact Info-->
<span class="bold_underlined">Contact Info:</span><br>
<em>📞 +1 917-722-2439</em><br> 📧
<em>&nbsp info#rtnyc.com </em><br>
<br>
<!--Location-->
<span class="bold_underlined">Access:</span><br>
<span id="metro"><strong>â“‚</strong> 23rd Street</span><br>
<em>119 W 23rd St, New York, NY 10011, USA</em>
</p>
<!--Embeded Map-->
<iframe src="https://snazzymaps.com/embed/187161" width="100%" height="250px" style="border:none;" title="Google Map of Rooftop Party location"></iframe>
</div>
</div>
</div>

If you want a simple fix, you can try put the id="photo" in the img element instead of the container (if no need to have a container).
<div> <!--Skyline Photo-->
<img id="photo" src="https://www.thepresslounge.com/wp-content/uploads/2014/06/Press_Lounge_0028-HDR-2-Edit-1600x900.jpg" alt="View from the rooftop." width="100%">
</div>
Styling in original code:
#photo {
border-width: 3%;
border-style: solid;
border-color: rgb(253, 0, 232);
}

Related

Offset child divs [duplicate]

This question already has answers here:
How to align two div next to each other
(7 answers)
Closed 3 months ago.
.titlebar {
font-family:'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
width: 100%;
display: inline-block;
margin: 0;
height: 125px;
background-color: rgb(0, 0, 0);
vertical-align: top;
}
.slogan {
text-align: right;
color: white;
font-size: 20px;
vertical-align: top;
padding: 10px;
}
.assets {
text-align: left;
color: white;
font-size: 20px;
vertical-align: top;
padding: 10px;
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="default.css">
</head>
<div class="titlebar">
<div class="assets">
123
</div>
<div class="slogan">
Hello
</div>
</div>
</html>
When adding more than one child to a parent div, the positions start offsetting. How can I make them level? I've tried vertical-align in both the children and the parents, but they remain offset.
That's because both divs come one after another; they take up space in the normal document flow. If you want them both in the same position, you could either
Set the parent div to have display: flex; and justify-content: space-between; (recommended solution):
.titlebar {
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
width: 100%;
display: inline-block;
margin: 0;
height: 125px;
background-color: rgb(0, 0, 0);
vertical-align: top;
/* 👇 */
display: flex;
justify-content: space-between;
}
.slogan {
text-align: right;
color: white;
font-size: 20px;
vertical-align: top;
padding: 10px;
}
.assets {
text-align: left;
color: white;
font-size: 20px;
vertical-align: top;
padding: 10px;
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="default.css">
</head>
<div class="titlebar">
<div class="assets">
123
</div>
<div class="slogan">
Hello
</div>
</div>
</html>
Add absolute positioning to both children (not recommended for your current situation, since absolute positioning removes elements from the normal document flow):
.titlebar {
font-family:'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
width: 100%;
display: inline-block;
margin: 0;
height: 125px;
background-color: rgb(0, 0, 0);
vertical-align: top;
}
.slogan {
text-align: right;
color: white;
font-size: 20px;
vertical-align: top;
padding: 10px;
/* 👇 */
position: absolute;
right: 0;
}
.assets {
text-align: left;
color: white;
font-size: 20px;
vertical-align: top;
padding: 10px;
/* 👇 */
position: absolute;
left: 0;
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="default.css">
</head>
<div class="titlebar">
<div class="assets">
123
</div>
<div class="slogan">
Hello
</div>
</div>
</html>
The duplicate answer does answer this, but to answer your specific issue:
I changed your .titlebar to be a flex parent (no reason in your code to be inline), and set the justify-content: space-between property.
.titlebar {
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
width: 100%;
/* changed this */
display: flex;
margin: 0;
height: 125px;
background-color: rgb(0, 0, 0);
vertical-align: top;
/* added this */
justify-content: space-between;
}
.slogan {
text-align: right;
color: white;
font-size: 20px;
vertical-align: top;
padding: 10px;
}
.assets {
text-align: left;
color: white;
font-size: 20px;
vertical-align: top;
padding: 10px;
}
<div class="titlebar">
<div class="assets">
123
</div>
<div class="slogan">
Hello
</div>
</div>

How can I solve this problem with an image and the nav in CSS

The problem is that when I place an image with absolute position and it passes the background of the nav, the image goes over the nav, and the idea is that it goes behind the nav [enter image description here][1]
Example:
[1]: https://i.stack.imgur.com/ZsXWN.png
Code CSS:
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: #110047;
color: white;
background-image: url("data:image/svg+xml,%3Csvg width='44' height='12' viewBox='0 0 44 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 12v-2L0 0v10l4 2h16zm18 0l4-2V0L22 10v2h16zM20 0v8L4 0h16zm18 0L22 8V0h16z' fill='%2308778e' fill-opacity='0.4' fill-rule='evenodd'/%3E%3C/svg%3E");
font-size: 14px;
font-family: 'Alfa Slab One', cursive;
}
header {
background: url('img/untitled.png') no-repeat center;
background-attachment: fixed;
}
#title {
width: 100%;
height: 49vh;
padding-bottom: 827px;
}
#titlex {
margin-top: 260px;
margin-left: 380px;
font-size: 110px;
font-family:'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
color: rgb(0, 68, 255);
position: fixed;
}
#titley {
margin-top: 260px;
margin-left: 370px;
font-size: 110px;
font-family:'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
color: rgb(0, 132, 255);
}
ul {
list-style: none;
}
a {
color: white;
text-decoration: none;
}
/* NAVIGATION */
.nav-main {
background-color: black;
position: fixed;
font-size: 30px;
display: flex;
justify-content: space-between;
align-items: center;
height: 60px;
padding: 20px;
}
.map {
margin-top: 100px;
width: 150px;
width: 7%;
margin-left: 180px;
margin-right: 120px;
}
.nav-main ul {
margin-left: 120px;
display: flex;
}
.nav-main ul li {
padding: 0px;
}
.nav-main ul li a {
margin-top: 130px;
cursor: pointer;
display: inline-block;
margin-right: 20px;
margin-left: 40px;
border: 0;
color: #fff;
font-size: 20px;
transition-duration: 0.5s;
transition-property: all;
font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
.nav-main ul li a:hover {
border-bottom: 3px solid rgb(69, 131, 212);
color:rgb(69, 131, 212);
padding-bottom: 3px;
}
/* ABOUT US */
#about {
background-image: url('img/ublogoa.png');
background-repeat: no-repeat;
background-position-y: 40px;
background-position-x: 1000px;
background-color: #fff;
padding-bottom: 400px;
}
.lol {
margin-top: 70px;
position: absolute;
display: block;
width: 80%;
height: auto;
margin-left: -250px;
}
#about1 {
background-image: url('img/blacktetas.png');
background-repeat: no-repeat;
background-position-y: 40px;
}
#titlea {
padding-top: 70px;
color: rgb(151, 151, 151);
margin-left: 605px;
font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
#under {
margin-left: 600px;
color:rgb(47, 103, 255);
font-size: 50px;
font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
#dialog1 {
margin-left: 600px;
margin-right: 150px;
margin-top: 50px;
color:rgb(151, 151, 151);
font-size: 17px;
font-family:'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
#dialog2 {
margin-left: 600px;
margin-top: 30px;
margin-right: 150px;
color:rgb(151, 151, 151);
font-size: 17px;
font-family:'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
#dialog3 {
margin-left: 600px;
margin-top: 30px;
margin-right: 150px;
color:rgb(151, 151, 151);
font-size: 17px;
font-family:'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
#dialog4 {
margin-left: 600px;
margin-top: 30px;
margin-right: 150px;
color:rgb(151, 151, 151);
font-size: 17px;
font-family:'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
Code HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UnderBlocks</title>
<link rel="stylesheet" href="style.css">
<link rel="icon" type="image/png" href="img/ublogoa.png">
</head>
<header>
<div id="title">
<div class="nav">
<nav class="nav-main">
<ul class="nav-menu">
<li>
<a class="left" href="#about-us">ABOUT US</a>
</li>
<li>
<a class="left" href="#marketplace">MARKETPLACE</a>
</li>
<img src="img/whitelogo.png" alt="Marketplace Logo" class="map">
<li>
<a class="right" href="#contact-us">CONTACT US</a>
</li>
<li>
<a class="right" href="#portfolio">PORTFOLIO</a>
</li>
</ul>
</nav>
</div>
</div>
</header>
<body>
<a name="about-us">
<div id="about">
<img src="img/sheguel.png" alt="Render Minecraft" class="lol">
<h3 id="titlea">ABOUT</h3>
<h1 id="under">UNDERBLOCKS</h1>
<h4 id="dialog1">UnderBlocks, is a Studio focused on creating content for the Mojang or Minecraft Marketplace, which has been uploading content to the Marketplace for more than 6 months, and will continue to upload content for the public, we focus on uploading maps, skinpacks, texturepacks, add-ons and more for the entire Minecraft community to enhance its gameplay in a potential way.</h4>
<h4 id="dialog2">Our main objective is to create the best content for the Minecraft public, respecting the Mojang rules and conditions to be able to upload our content, for all the public, every day we have new ideas to improve and expand UnderBlocks, and every day we have new projects. which we have planned to upload after everything is finished and with 0 failures</h4>
<h4 id="dialog3">We have managed to upload our first content to the Marketplace on August 25, 2020, it was a day of celebration for the entire UnderBlocks team, since it would be our first content uploaded to the public from the Marketplace, after that we continue to be inspired by upload more content and every day more excited to upload our types of content, skinpacks, maps, add-ons and more</h4>
<h4 id="dialog4">On August 22 we finally managed to become an official partner with Mojang and be able to upload our content from our own hands to the Marketplace, as our first content uploaded was a day of joy and happiness, and we returned inspired by uploading new types of content and we will continue uploading great types of content for the Minecraft community</h4>
</div>
<a name="portfolio">
<div id="portfolio">
</div>
<script src="scripts/main.js"></script>
</body>
</html>
These are the codes of the web, the image its class is lol, please I need help

How to change position of the submit button inside a form?

My HTML code:
body{
font-family: cursive;
font-size: 25px;
font-weight: bold;
background-color: rgba(95, 112, 160, 0.479);
}
h2{
display: block;
border: 2px solid black;
text-align: center;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
#details{
display: block;
background-color:rgba(28, 117, 190, 0.726);
}
#back{
font-size:20px;
margin-left: 100px;
border-radius: 8px;
}
#go{
font-size:20px;
margin-left: 800px;
border-radius: 8px;
}
<body>
<h2>Please finalize your details</h2>
<form id="details" action=database_registration.php method="post" class="form">
Full name: <strong name="name_1" value=""></strong><br><br>
ID No:<strong name="org_number_1" value=""></strong><br><br>
Mobile No:<strong name="ph_number_1" value=""></strong><br><br>
E-mail: <strong name="email_1"></strong><br><br>
ID Card: <img src="" alt="preview" name="image" style="width: 100px; height: 100px;" value=""><br><br>
<button id="go" style="background-color: whitesmoke">It's correct</button>
</form>
<button id="back" style="background-color: whitesmoke" onclick="goback()">Something's wrong</button>
<p id="response"></p>
</body>
As you can see, the button It's correct is inside the blue display block. I want to re-position it a little below. Please help me fix this.
I want both the buttons to be outside the blue display and at the same height.
To put it below the blue box, you simply have to add margin-bottom: (value); and adjust a couple of things (see details below)
See the example below:
body{
font-family: cursive;
font-size: 25px;
font-weight: bold;
background-color: rgba(95, 112, 160, 0.479);
}
h2{
display: block;
border: 2px solid black;
text-align: center;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
#details{
display: block;
background-color:rgba(28, 117, 190, 0.726);
}
#back{
font-size:20px;
margin-left: 100px;
border-radius: 8px;
}
#go{
font-size:20px;
margin-left: 300px;
border-radius: 8px;
margin-bottom: 800px;
}
<body>
<h2>Please finalize your details</h2>
<form id="details" action=database_registration.php method="post" class="form">
Full name: <strong name="name_1" value=""></strong><br><br>
ID No:<strong name="org_number_1" value=""></strong><br><br>
Mobile No:<strong name="ph_number_1" value=""></strong><br><br>
E-mail: <strong name="email_1"></strong><br><br>
ID Card: <img src="" alt="preview" name="image" style="width: 100px; height: 100px;" value=""><br><br>
</form>
<button id="back" style="background-color: whitesmoke" onclick="goback()">Something's wrong</button>
<button id="go" style="background-color: whitesmoke">It's correct</button>
<p id="response"></p>
</body>
So there's a couple of things I changed, your go button HTML needed to be at the same position as the back button and I switched the position of that whole line in your HTML code. Second, I adjusted the margin-left since your button was way off. Also, I added margin-bottom to again adjust the positioning of your button. As per your request, you wanted it below the form in which this code accomplishes that task, but let me know if there is something else missing.
If the button is used to submit the form, it needs to be inside the form.
You also have a distinct lack form elements which I have addressed.
Encapsulate all but the buttons in a filedset. Then create a specific div to hold the buttons and use flex and justify-content to position the buttons.
body {
font-family: cursive;
font-size: 25px;
font-weight: bold;
background-color: rgba(95, 112, 160, 0.479);
}
h2 {
display: block;
border: 2px solid black;
text-align: center;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
#details label {
display: block;
margin-bottom: 1.5em;
}
#details fieldset {
background-color: rgba(28, 117, 190, 0.726);
border: none;
}
#details input {
font-size: 25px;
font-weight: bold;
border: none;
background: none;
font-family: cursive;
}
.buttons {
display: flex;
margin: 0.5em;
justify-content: space-between;
}
.buttons button {
font-size: 20px;
border-radius: 8px;
}
<body>
<h2>Please finalize your details</h2>
<form id="details" action=database_registration.php method="post" class="form">
<fieldset>
<label>Full name: <input name="name_1" value=""></label>
<label>ID No:<input name="org_number_1" value=""></label>
<label>Mobile No:<input name="ph_number_1" value=""></label>
<label>E-mail: <input name="email_1"></label>
<div>ID Card: <img src="" alt="preview" name="image" style="width: 100px; height: 100px;" value=""></div>
</fieldset>
<div class="buttons">
<button id="back" style="background-color: whitesmoke" onclick="goback()">Something's wrong</button> <button id="go" style="background-color: whitesmoke">It's correct</button>
</div>
</form>
<p id="response"></p>
</body>

image and textbox align with each other

I am trying to create an event list with image on the left hand side, and text box on the right hand side describing it (similar to evenbrite). However, I am having the following issues:
creating a box for the text
align the image with the box
change the padding, margin of the text so that it fits inside the box.
Thank you!
html:
<img src="bionic.jpg" alt="festo bionic" class="events">
<div class="event_description">
<p> Robotics Demo </p>
<p> All Day on October 4th, 2018. R:Lab, Emirates Tower</p>
<p> Join us in interacting with the most technologically advanced robots. </p>
</div>
css:
body {
text-align: center;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
padding: 0;
margin: 0;
}
h1 {
color: rgb(65, 56, 50);
font-size: 6em;
padding: 0px;
}
h2 {
color: rgb(61, 23, 30);
font-size: 3em;
}
img {
height: 350px;
}
p {
color: rgb(61, 23, 30);
padding: 30px;
font-size: 1.5em;
}
.events {
float:left;
height:200px;
width: 200px;
margin: 20px;
}
.event_description {
display:inline-block;
font-size: 1.0em;
float:right;
margin: auto;
padding: 0px;
border:5px lightgray;
}
Is this what you want? I have made the width of event_description
width: calc(100% - 240px);
This will align the description next to image
How this works
width: calc(100% - 240px);
240px is sum of width of the image and the margin applied to the image
You are subtracting 240px from the width of the parent.
body {
text-align: center;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
padding: 0;
margin: 0;
}
h1 {
color: rgb(65, 56, 50);
font-size: 6em;
padding: 0px;
}
h2 {
color: rgb(61, 23, 30);
font-size: 3em;
}
img {
height: 350px;
}
p {
color: rgb(61, 23, 30);
padding: 30px;
font-size: 1.5em;
}
.events {
float: left;
height: 200px;
width: 200px;
margin: 20px;
}
.event_description {
width: calc(100% - 240px);
display: inline-block;
font-size: 1.0em;
float: right;
margin: auto;
padding: 0px;
border: 5px lightgray;
}
<img src="https://placehold.it/100x100" alt="festo bionic" class="events">
<div class="event_description">
<p> Robotics Demo </p>
<p> All Day on October 4th, 2018. R:Lab, Emirates Tower</p>
<p> Join us in interacting with the most technologically advanced robots. </p>
</div>
See if that's what you want.
I created an element <div class="content"></div> which will be the parent of the elements, and set the following property: display: flex;.
To set the border of .events_description the added solid
.content {
display: flex;
}
p {
color: rgb(61, 23, 30);
}
.events {
height:200px;
width: 200px;
margin-right: 30px;
}
.event_description {
flex-wrap:wrap;
display:inline-block;
font-size: 16px;
padding: 0px 15px 0 0;
border:5px solid lightgray;
}
p {
margin: 0;
}
<div class="content">
<img src="https://www.gettyimages.co.uk/gi-resources/images/Embed/new/embed1.jpg" alt="festo bionic" class="events">
<div class="event_description">
<p> Robotics Demo </p>
<p> All Day on October 4th, 2018. R:Lab, Emirates Tower</p>
<p> Join us in interacting with the most technologically advanced robots. </p>
</div>
</div>

aligning an image horizontally to the right of text in CSS within a larger Div

I need images for the Top , Middle and Bottom to be on the right hand side of the text within these divs. at the moment even though the images go right and text left the image sits below the paragraphs position. I have applyed a reset.css already as well.
Here is the relevent HTML and CSS
Index.html extract:
<Div id="background">
<div id="Space">
</div><!--spacing between divs-->
<article id="Top">
<h2>Flower arrangement</h2>
<p>Our team of professional designers will make your event memorable and stress free. We will design to your theme, colour, budget and needs with attention to detail given high priority.</p>
<img src="Images/Top_Image.gif" alt="" width="207" height="195">
<a href="#" >Read More </a>
</article>
<div id="Top_box">
</div><!--spacing between divs-->
<article id="Middle">
<h2>Seed Library</h2>
<p>Don't be afraid to try growing your own plants, you will be surprised how easy seed germination really is. A large variety of native seed mixes are offered, ideal for creating sustainable wildflower gardens.</p>
<a href="#" >Read More </a>
<img src="Images/Middle_picture.gif" alt="" width="208" height="216">
</article>
<div id="Middle_box">
</div><!--spacing between divs-->
<article id="Review">
<h2>Ran Dome said:</h2>
<p>'I have never had such an outstanding experience with such a wonderful group of people who understood my needs'</p>
<img src="Images/Review_picture.gif" alt="" width="93" height="120">
</article>
<div id="Review_box">
</div><!--spacing between divs-->
<article id="Bottom">
<h2>Sustainability</h2>
<p>Belinda Aspect founded Aspect in April 1985 and is a leading expert on green floral design. Belinda's dual passions for floral design and sustainability were merged when she decided that The Aspect would 'go green'.</p>
<a href="#" >Read More </a>
<img src="Images/Bottom_picture.gif" alt="" width="208" height="216">
</article>
<div id="Bottom_box">
</div><!--spacing between divs-->
</Div><!--background picture Div-->
style.css extract:
#background {
background-image: url(Images/background.jpg);
background-repeat: no-repeat;
width:100%;
}
#catch_line{
color: #7f6e99;
height: 50%px;
width: 57%;
margin-left: 6%;
margin-top:132px;
background-color: #000000;
border-radius: 5px;
}
#catch_line h1{
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 3.4em;
padding-top: 10px;
padding-left: 10px;
padding-bottom: 10px;
paddingtop: 50px;
color: #7f6e99;
}
article#Top, article#Review {
width: 100%;
height: 200px;
border-radius: 5px;
background-color: #7a9c52;
}
article#Middle, article#Bottom {
width: 100%;
height: 200px;
border-radius: 5px;
background-color: #2d6d18;
}
article#Top h2, article#Middle h2, article#Bottom h2 {
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 1.6em;
color: #0c1306;
padding-bottom: 2%;
word-spacing: 2px;
padding-top: 3%;
padding-left: 6%;
margin right: 0px;
}
article#Top p, article#Middle p, article#Bottom p{
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 1em;
color: #0c1306;
width: 70%;
clear: none;
display:block;
padding-left: 6%;
padding-bottom: 2%;
margin right: 0px;
}
article#Top a, article#Middle a, article#Bottom a {
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 0.7em;
color: #dc3646;
text-decoration: none;
clear: none;
float: left;
padding-left: 6%;
margin right: 0px;
}
article#Top img, article#Middle img, article#Bottom img{
float: right;
margin-right: 20px;
clear: none;
width: 140px;
height: 140px;
display:block;
margin left: 0px;
}
article#Review h2 {
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 1.6em;
color: #0c1306;
padding-bottom: 2%;
word-spacing: 2px;
padding-top: 2.5%;
text-align: center;
}
article#Review p {
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-style: italic;
font-size: 1em;
color: #0c1306;
text-align:center;
padding-left: 10%;
padding-right: 10%;
padding-bottom: 0.5%;
}
article#Review img{
margin-left: auto;
margin-right: auto;
display:block;
height: 78px;
width:62px;
}
#Space, #Top_box, #Middle_box, #Review_box, #Bottom_box{
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
height: 80px;
clear: both;
}
I am also aware that I could change it so that the articles have margins instead and get rid of the spacing divs to get the same effect as what I want from them but I'm not concerned with that at the moment.