I have a div container with some text in it, and a back button. I want the text to be at the top of the div and the back button to be at the bottom of the div. How do I do this? Jsfiddle example of it
#view {
text-align: center;
width: 700px;
height: 700px;
background-color: #197000;
margin: auto;
padding: 20px;
border-radius: 10px;
margin-top: 50px;
margin-bottom: 50px;
font-weight: 400;
font-family: 'Montserrat', sans-serif;
}
#view_back_button {
vertical-align: bottom;
border-radius: 25px;
border: 2px solid #B40000;
background: none;
color: #060606;
width: 150px;
font-weight: 400;
font-size: 12px;
cursor: pointer;
padding: 15px;
font-family: 'Montserrat', sans-serif;
}
<div id="view">
<h1>Name</h1>
<p>Allergies: </p>
<p>Side effects: </p>
<p>Type of medication: </p>
<p>Additional information: </p>
<div id="view_button">
<form>
<button id="view_back_button" type="submit">BACK</button>
</form>
</div>
</div>
Is it useful for you? I just added position: relative; to your container and then used absolute,left,right and bottom to locate it.
#view {
text-align: center;
width: 700px;
height: 700px;
background-color: #197000;
margin: auto;
padding: 20px;
border-radius: 10px;
margin-top: 50px;
margin-bottom: 50px;
font-weight: 400;
font-family: 'Montserrat', sans-serif;
position: relative;
}
#view_back_button {
vertical-align: bottom;
border-radius: 25px;
border: 2px solid #B40000;
background: none;
color: #060606;
width: 150px;
font-weight: 400;
font-size: 12px;
cursor: pointer;
padding: 15px;
font-family: 'Montserrat', sans-serif;
}
#view_button {
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin-bottom: 50px;
}
<div id="view">
<h1>Name</h1>
<p>Allergies: </p>
<p>Side effects: </p>
<p>Type of medication: </p>
<p>Additional information: </p>
<div id="view_button">
<form>
<button id="view_back_button" type="submit">BACK</button>
</form>
</div>
</div>
Archive by revise some css code like below:
#view {
position: relative; /* add */
text-align: center;
width: 700px;
height: 700px;
background-color: #197000;
margin: auto;
padding: 20px;
border-radius: 10px;
margin-top: 50px;
margin-bottom: 50px;
font-weight: 400;
font-family: 'Montserrat', sans-serif;
}
#view_button { /* add */
position: absolute;
bottom: 30px;
width: 100%;
}
#view_back_button {
/* vertical-align: bottom; */
border-radius: 25px;
border: 2px solid #B40000;
background: none;
color: #060606;
width: 150px;
font-weight: 400;
font-size: 12px;
cursor: pointer;
padding: 15px;
font-family: 'Montserrat', sans-serif;
}
<div id="view">
<h1>Name</h1>
<p>Allergies: </p>
<p>Side effects: </p>
<p>Type of medication: </p>
<p>Additional information: </p>
<div id="view_button">
<form>
<button id="view_back_button" type="submit">BACK</button>
</form>
</div>
</div>
#view {
text-align: center;
width: 700px;
height: 700px;
background-color: #197000;
margin: auto;
padding: 20px;
border-radius: 10px;
margin-top: 50px;
margin-bottom: 50px;
font-weight: 400;
font-family: 'Montserrat', sans-serif;
position: relative;
}
#view_back_button {
vertical-align: bottom;
border-radius: 25px;
border: 2px solid #B40000;
background: none;
color: #060606;
width: 150px;
font-weight: 400;
font-size: 12px;
cursor: pointer;
padding: 15px;
font-family: 'Montserrat', sans-serif;
margin-bottom: 20px;
}
#view_button {
position: absolute;
bottom: 0;
left: 0;
right: 0;
}
<div id="view">
<h1>Name</h1>
<p>Allergies: </p>
<p>Side effects: </p>
<p>Type of medication: </p>
<p>Additional information: </p>
<div id="view_button">
<form>
<button id="view_back_button" type="submit">BACK</button>
</form>
</div>
</div>
added position: relative to parent container and css for view_button
#view {
text-align: center;
width: 700px;
height: 700px;
background-color: #197000;
margin:auto;
padding: 20px;
border-radius: 10px;
margin-top: 50px;
margin-bottom: 50px;
font-weight: 400;
font-family: 'Montserrat', sans-serif;
position:relative; /* added */
}
/* added*/
#view_button {
position: absolute;
bottom:10px;
width:100%;
}
#view_back_button {
/* removed vertical-align */
border-radius: 25px;
border: 2px solid #B40000;
background: none;
color: #060606;
width: 150px;
font-weight: 400;
font-size: 12px;
cursor: pointer;
padding: 15px;
font-family: 'Montserrat', sans-serif;
}
<div id="view">
<h1>Name</h1>
<p>Allergies: </p>
<p>Side effects: </p>
<p>Type of medication: </p>
<p>Additional information: </p>
<div id="view_button">
<form>
<button id="view_back_button" type="submit">BACK</button>
</form>
</div>
</div>
Related
I've trying to make a website just for a home project but having some trouble with the css for mobile.
There seems to be a lot of whitespace surrounding the elements to the right and bottom of the site. I'm newer to the world of CSS so any help would be appreciated.
Screenshot of what chrome shows in developer mode.
#media screen and (max-width:450px) {
body {
margin: 0 0 0 0;
padding: 0 0 0 0;
max-width: 100vw;
overflow-x: hidden;
}
html{scroll-behavior:smooth}
.navbar {
background-color: #008B8B;
position: fixed;
top: 0;
z-index: 100;
width: 100vw;
}
.navbar a {
text-decoration: none;
display: inline-block;
float: center;
padding-bottom: 20px;
}
.logo{
display: none;
}
.loginLogo{
width = 1px;
height = 1px;
visibility: hidden;
}
.navbar-name{
color: #f2f2f2;
font-size:25px;
padding-left: 25%;
font-family: 'Lobster', cursive;
}
.navbar-home{
font-size: 17px;
padding-top: 5px;
padding-right: 10px;
float: right;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
}
.navbar-products{
font-size: 17px;
padding-top: 5px;
padding-right: 10px;
float: right;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
}
.navbar-about{
font-size: 17px;
padding-top: 5px;
padding-right: 10px;
float: right;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
}
.navbar-contact{
font-size: 17px;
padding-top: 5px;
padding-right: 17.5%;
float: right;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
}
.navbar-login{
font-size: 1px;
padding-top: 1px;
float: right;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
visibility: hidden;
}
/* Change the color of links on hover */
.navbar-home:hover {
color: black;
}
.navbar-products:hover {
color: black;
}
.navbar-about:hover {
color: black;
}
.navbar-contact:hover {
color: black;
}
.navbar-login:hover {
color: black;
}
/* Add a color to the active/current link */
.navbar a.active {
background-color: #4CAF50;
color: white;
}
/*--------HOME PAGE------------*/
.homePage{
margin: 0 0 0 0;
padding: 0;
width: 100vw;
height: 820px;
background-image: url(multiGrain.jpg);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.homePageH1{
position: absolute;
text-align: center;
overflow: hidden;
white-space: nowrap;
top: 26%;
left:50%;
transform: translateX(-50%) translateY(-50%);
font-size: 40px;
color: white;
}
.homePageH2{
position: absolute;
text-align: center;
display: inline;
top: 28%;
left: 50%;
text-align: center;
transform: translateX(-50%) translateY(-50%);
font-size: 20px;
color: white;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
display: inline-block;
}
.aboutUsButton{
position: absolute ;
text-align: center;
top: 31%;
left:30%;
padding: 10px;
padding-right: 20px;
padding-left: 20px;
transform: translateX(-50%) translateY(-50%);
background-color: rgb(0, 159, 159);
border-radius: 25px;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
text-decoration: none;
}
.ourProductsButton{
position: absolute ;
text-align: center;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
display: inline-block;
top: 31%;
left:70%;
padding: 10px;
padding-right: 18px;
padding-left: 18px;
transform: translateX(-50%) translateY(-50%);
background-color: rgb(0, 159, 159);
border-radius: 25px;
font-family: 'Titillium Web', sans-serif;
color: #f2f2f2;
text-decoration: none;
}
/*-------ABOUT US PAGE----------*/
.aboutUsPage{
margin: 0 0 0 0;
padding: 0px;
background-color: white;
height: auto;
width: 100%;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.aboutUsH1{
position: relative;
padding-top: 20px;
padding-left: 20px;
margin: 0px;
text-align: left;
display: block;
width: 90%;
top: 20%;
font-size: 20px;
font-family: 'Lobster', cursive;
color: black;
background-color: rgb(255,255,255);
}
.aboutUsP{
position: relative;
padding-top: 20px;
padding-left: 20px;
padding-bottom: 30px;
margin: 0px;
text-align: left;
float: bottom;
display: block;
width: 90%;
top: 5%;
font-size: 15px;
font-family: 'Lobster', cursive;
color: black;
background-color: rgb(255,255,255);
}
.mixerImage{
position: relative;
object-fit: cover;
width: 100%;
height: 150px;
}
/*--------PRODUCTS PAGE------------*/
.productsPage{
position: relative;
margin: 0px;
padding: 0px;
background-color: white;
height: 300px;
width: auto;
}
.productsH1{
position: relative;
text-align: left;
top: 5%;
left: 4%;
font-size: 25px;
font-family: 'Titillium Web', sans-serif;
color: black;
}
.productsP{
position: relative;
padding: 10px;
padding-top: 15px;
text-align: left;
float: inherit;
width: 45%;
left: 2%;
font-size: 15px;
font-family: 'Titillium Web', sans-serif;
color: black;
background-color: white;
}
.productListButton{
position: absolute ;
text-align: center;
left: 2%;
padding: 10px;
padding-right: 20px;
padding-left: 20px;
background-color: black;
border-radius: 25px;
font-family: 'Titillium Web', sans-serif;
letter-spacing: 5px;
color: white;
text-decoration: none;
}
.slideshowImage1{
position: absolute;
width: auto;
left: 55%;
top: 15%;
height: 100px;
float: right;
margin: 10px;
padding: 10px;
box-shadow: 0 0 20px rgba(0,0,0,0.4);
}
.slideshowImage2{
width = 0px;
height = 0px;
visibility: hidden;
}
/*-------CONTACT US PAGE---------*/
.contactPage{
margin: 0 0 0 0;
padding: 0px;
background-image: url(rollingPin2.JPG);
height: 700px;
width: 100%;
background-repeat: no-repeat;
background-size: cover;
background-size: 200% 100%;
}
.contactH1{
position: relative;
text-align: center;
overflow: hidden;
white-space: nowrap;
top: 10%;
left:0%;
font-size: 70px;
letter-spacing: 3px;
color: white;
font-family: 'Dancing Script', cursive;
}
.contactP1{
position: relative;
text-align: center;
top: 10%;
left:0%;
font-size: 18px;
color: white;
font-family: 'Slabo 27px', serif;
}
.contactP2{
position: relative;
text-align: center;
top: 10%;
left:0%;
font-size: 18px;
color: white;
font-family: 'Slabo 27px', serif;
}
.contact-form{
position: relative;
top: 15%;
width: 80%;
left: 47.5%;
transform: translateX(-50%);
}
input[type=text], select, textarea {
width: 100%; /* Full width */
padding: 12px; /* Some padding */
border: 1px solid #ccc; /* Gray border */
font-family: 'Titillium Web', sans-serif;
border-radius: 4px; /* Rounded borders */
margin-top: 6px; /* Add a top margin */
margin-bottom: 16px; /* Bottom margin */
resize: none; /* Allow the user to vertically resize the textarea (not horizontally) */
}
/* Style the submit button with a specific background color etc */
input[type=submit] {
width: 105%;
background-color: #008B8B;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
/* When moving the mouse over the submit button, add a darker green color */
input[type=submit]:hover {
background-color: black;
}
.nameInput{
position: relative;
top: 0px;
color: white;
}
.emailInput{
position: relative;
top: 5px;
color: white;
}
.messageInput{
position: relative;
top: 5px;
color: white;
}
.submitButton{
position: relative;
top: 5px;
}
/*--------FOOTER---------*/
.facebookLogo{
width: 0%;
height: 0%;
visibility: hidden;
}
.footer {
width: 0px;
height: 0px;
visibility: hidden;
}
.footerp1{
width: 0px;
height: 0px;
visibility: hidden;
}
.footerp2{
width: 0px;
height: 0px;
visibility: hidden;
}
.footerp3{
width: 0px;
height: 0px;
visibility: hidden;
}
}
<!DOCTYPE html>
<html>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=yes">
<link href="https://fonts.googleapis.com/css2?family=Titillium+Web:wght#600&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Lobster&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Dancing+Script&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Slabo+27px&display=swap" rel="stylesheet">
<title>Doughboys Bakery</title>
<link href="StyleSheet.css" rel="stylesheet">
</head>
<body>
<header class="site-header">
<nav class="navbar">
<img class = "logo" src="Doughboys Logo - Website Version.png" alt="Logo" width="80"height="45.109">
<a class="navbar-name" href="">Doughboy's Bakery.</a>
<a class="navbar-login" href="">Log In</a>
<img class = "loginLogo" src="loginLogo2.png" onmouseover="this.src='loginLogo2Black.png';" onmouseout="this.src='loginLogo2.png';" width="50"height="28.889"/>
<a class="navbar-contact" href="#contactPage">Contact</a>
<a class="navbar-products" href="#productsPage">Products</a>
<a class="navbar-about" href="#aboutUsPage">About</a>
<a class="navbar-home" href="#homePage">Home</a>
</nav>
</header>
<div class = "homePage" id="homePage">
<h1 class="homePageH1">Quality or Quantity</h1>
<h2 class="homePageH2">We're here to give you both</h2>
<div class = "homePageButtons">
<a class="aboutUsButton" href="#aboutUsPage">About Us</a>
<a class="ourProductsButton" href="#productsPage">Our Products</a>
</div>
</div>
<div class = "aboutUsPage" id="aboutUsPage">
<div class = "aboutUsText">
<h1 class="aboutUsH1">Who we are.</h1>
<p class="aboutUsP">Doughboys Bakery is a locally owned and operated wholesale bakery located near the city centre of Palmerston North. We produce traditional bakery goods like the classic Mince and Cheese Pies and Custard Squares. <br/><br/>We deliver actively in the Manawatu-Whanganui, Horowhenua & Wairarapa regions. (T's & C's Apply)<br/><br/>Use the contact section below to see how we can help suit your baking needs.</p>
</div>
</div>
<div class = "productsPage" id="productsPage">
<h1 class="productsH1">What we make.</h1>
<p class="productsP">At Doughboys' we supply traditionally sold bakery goods all the way from the classic Mince and Cheese Pie to the humble Scone.</p>
<button class="productListButton" type="submit" onclick="window.open('ProductList.doc')">Full Product List</button>
<div id="slideshow">
<div>
<img class="slideshowImage1" src="fruitPies.jpeg">
</div>
<div>
<img class="slideshowImage2" src="pies.jpg">
</div>
</div>
</div>
<div class="contactPage" id="contactPage">
<h1 class="contactH1">Contact Us.</h1>
<p class="contactP1">ADDRESS: 15 Johnston St </p>
<p class="contactP2">TEL: (06) 123 1234 | doughboys#gmail.net.nz</p>
<div class = "contact-form">
<form id = "contact-form" method="post" action="contactForm.php">
<input class= "nameInput" type="text" id="name" name="name" placeholder="Your name...">
<input class= "emailInput" type="text" id="email" name="email" placeholder="Your email...">
<textarea class= "messageInput" id="message" name="message" placeholder="Write something..." style="height:100px"></textarea>
<input class= "submitButton" type="submit" value="Submit">
</form>
</div>
</div>
<div class="footer">
<a href="https://www.facebook.com/Doughboys-Bakery-Ltd-216199385212667">
<img class = "facebookLogo" src="facebookLogo.png" >
</a>
<p class="footerp1">(06) 123 1234</p>
<p class="footerp2">doughboys#gmail.net.nz</p>
<p class="footerp3">15 Johnston St</p>
</div>
</body>
</html>
I am trying to add two images in one row and it should go on continuously in a vertical direction but the issue I am facing is I am getting space between the images vertically.
I tried to add CSS but it did not work. (note: I am looping through images so I can't apply CSS for different images, it needs to be applicable to all images at once)
.menu-spacer {
flex: 1 1 auto;
}
a {
padding-right: 5em;
}
.menu-spacer1 {
flex: 1 1 auto;
padding-top: 15em;
}
#second-row {
margin-top: 2em;
}
#first-row {
border-top-left-radius: 3em;
box-shadow: 0 16px 24px 2px rgb(245, 245, 248), 0 6px 15px 1px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.3);
}
#search-button {
margin-left: 7em;
border-radius: 2em;
width: 24em;
height: 30px;
outline-style: none;
text-align: center;
border-width: 2px;
border-color: black;
}
#mn {
height: 12em;
}
h1 {
color: white;
margin-left: 2em;
margin-top: 3em;
font-size: 28px;
}
#img {
margin-top: 9em;
padding: 0;
width: 12em;
margin-left: 2em;
}
#img1 {
height: 13em;
padding: 0em;
}
#img2 {
float: right;
/* float: top; */
height: 13em;
position: relative;
top: -15em;
}
.example-card {
padding: 0em;
}
p {
margin-top: 10em;
margin-left: -214px;
color: #e67500;
font-size: 15px;
font-family: ProximaNova, Arial, Helvetica Neue, sans-serif;
}
h2 {
margin-top: 12em;
margin-left: -567px;
color: #e67500;
font-size: 15px;
font-family: ProximaNova, Arial, Helvetica Neue, sans-serif;
}
#rating {
font-size: 15px;
margin-top: 16em;
margin-left: -95px;
color: white;
}
mat-icon {
font-size: 15px;
position: relative;
top: 2px;
left: 5px;
}
#ratingcount {
font-size: 12px;
color: #e67500;
margin-top: 24em;
margin-left: -39px;
}
#time {
font-size: 16px;
margin-top: 15em;
margin-left: -32em;
color: white;
}
#timealias {
font-size: 12px;
margin-top: 24em;
margin-left: -5em;
color: #e67500;
}
#cost {
font-size: 16px;
color: white;
margin-top: 15em;
position: relative;
right: 32em;
}
#costalias {
position: relative;
font-size: 12px;
top: 12em;
left: -45em;
color: #e67500;
}
.mat-divider {
color: white;
background-color: yellow;
height: 43px;
position: relative;
left: -554px;
top: 132px;
}
/* #right-content{
margin-left: 74em;
margin-top: -13em;
} */
#menu-img {
margin-right: 4em;
/* margin-top: 6em; */
height: 13em;
margin-top: 0em;
/* vertical-align: bottom; */
}
#menu-name {
margin-left: 1.5em;
margin-top: 1em;
color: #282c3f;
font-size: 15px;
font-weight: 500;
font-family: Roboto, "Helvetica Neue", sans-serif;
}
#veg-img {
position: relative;
top: 115px;
right: 332px;
width: 15px;
}
#menu-type {
position: relative;
top: -10em;
left: 236px;
font-family: ProximaNova, Arial, Helvetica Neue, sans-serif;
color: #7e808c;
font-size: 13px;
}
#menu-price {
position: relative;
top: -275px;
right: -236px;
color: #535665;
font-size: 15px;
}
.menu-button {
color: green;
background-color: white;
border-color: yellowgreen;
position: relative;
top: -319px;
left: 194px;
width: 5em;
height: 2em;
border-style: solid;
}
<app-swiggy-header></app-swiggy-header>
<div class="row-6" id="second-row">
<mat-toolbar [ngStyle]="{'backgroundColor': '#171a29'}" id="mn">
<mat-toolbar-row>
<img src="assets/swiggyimages/moriz.jpg" id="img">
<h1>Moriz Restaurant</h1>
<p>Fast Food, Snacks, Pastas, Salads, Beverages, Home Food, Italian, North Indian, Ma</p>
<h2>ACES Layout</h2>
<span id="rating">
<mat-icon>star</mat-icon>4.5
</span>
<span id="ratingcount">100+ Ratings</span>
<hr>
<mat-divider vertical></mat-divider>
<span id="time">30 mins</span>
<span id="timealias">Delivery Time</span>
<hr>
<mat-divider vertical></mat-divider>
<span id="cost">150</span>
<span id="costalias">Cost for two</span>
</mat-toolbar-row>
</mat-toolbar>
</div>
<div class="row">
<div class="col-3" id="left-content">abc</div>
<div class="col-xs-12 col-md-8">
<div class="row">
<div class="col-xs-4 ">
<img src="assets/swiggyimages/moriz.jpg" class="img-responsive" alt="Logo" id="menu-img">
<img src="assets/swiggyimages/veg.png" id="veg-img">
<p id="menu-name">Paneer-Veg-Biryani</p>
<p id="menu-type">Rice</p>
<p id="menu-price">105</p>
<button class="menu-button">ADD</button>
</div>
<div class="col-xs-4 ">
<img src="assets/swiggyimages/moriz.jpg" class="img-responsive" alt="Logo" id="menu-img">
<img src="assets/swiggyimages/veg.png" id="veg-img">
<p id="menu-name">Paneer-Biryani</p>
<p id="menu-type">veg</p>
<p id="menu-price">105</p>
<button class="menu-button">ADD</button>
</div>
<div class="col-xs-4 ">
<img src="assets/swiggyimages/moriz.jpg" class="img-responsive" alt="Logo" id="menu-img">
<img src="assets/swiggyimages/veg.png" id="veg-img">
<p id="menu-name">Paneer-Biryani</p>
<p id="menu-type">veg</p>
<p id="menu-price">105</p>
<button class="menu-button">ADD</button>
</div>
<div class="col-xs-4 ">
<img src="assets/swiggyimages/moriz.jpg" class="img-responsive" alt="Logo" id="menu-img">
<img src="assets/swiggyimages/veg.png" id="veg-img">
<p id="menu-name">Paneer-Biryani</p <p id="menu-type">veg</p>
<p id="menu-price">105</p>
<button class="menu-button">ADD</button>
</div>
</div>
</div>
<div class="col-3" id="right-content">mnc</div>
</div>
I have an h1 tag in a div, and I would like for it to be pushed down from right up to the top of the div. I have tried adding a top margin on the h1 but that doesn't help. When I put some text in the div '#contact', Suddenly the h1 moves down. Is there a way to move the h1 down without text in '#contact'? Thank you in advance.
Snippet:
<div style="float:left; margin: 0; width: 100%;background-color:#eeeeee;font-size: 20px;color: #252a30;text-align: center;">
<style>
.half {
width: 40%;
margin: 3%;
font-size: 0.7em;
display: block;
}
.hl {
text-align: left;
float: left;
}
.hr {
text-align: right;
float: right;
}
.project-tags {
color: #b2c6cd;
font-size: 0.9rem;
font-weight: 700;
letter-spacing: 1px;
opacity: 1;
text-transform: uppercase;
}
.half ul, .half h1 {
margin-bottom: 0px;
margin-top: 0px;
}
.half h1 {
margin-bottom: 5px;
}
.project-tags li {
color: #fed766;
}
.project-tags span {
color: #b2c6cd;
}
.half p {
font-weight: 300;
font-size: 20px;
}
.button-primary {
margin: 10px 0 60px;
color: #252a30;
background-color: rgba(0, 0, 0, 0);
border: 2px solid #FED766;
height: auto;
font-size: 1rem;
line-height: normal;
text-transform: uppercase;
font-weight: 700;
transition: all .3s ease-in-out;
letter-spacing: 0;
border-radius: 50px;
display: inline-block;
text-align: center;
text-decoration: none;
white-space: nowrap;
cursor: pointer;
box-sizing: border-box;
outline: 0;
padding: 1.0rem 3.0rem;
}
.button-primary:hover {
color: #FED766;
background-color: #252a30;
border: 2px solid #252a30;
padding: 1.0rem 3.5rem;
}
.on-ylw {
border: 2px solid #252a30;
}
</style>
<p id="projects"></p>
<h1>My Projects</h1>
<p style="font-weight: 300;">Examples of my work</p>
<div class="projects" style="margin: 0 15%;">
<div class="half hl">
<h1>Text</h1>
<ul class="project-tags">
<li><span>Python</span></li>
</ul>
<p>Text</p>
Visit Website
</div>
<div class="half hr">
<img src="image" alt="link" style="border-radius: 10px;position: relative: width: 100%; border-style: none;">
</div>
</div>
</div>
<div style="margin: 0; width: 100%; background-color: #FED766;position: static;">
<div id="contact"></div>
<br>
<br>
<h1 style="text-align: center; font-weight: bold; color: #000000; font-size: 40px;">Want To Contact Me</h1>
<p style="text-align: center; font-weight: 300; font-size: 25px; color: #000000;">I'm currently accepting new projects and would love to hear about yours.</p>
<br>
<button class="button-primary on-ylw" style="display: table; margin: 0 auto;">Contact Me</button>
<br>
<br>
</div>
Add:
clear: both;
property to the <div> that the h1 is in.
The div up the DOM you have float: left; therefore it's not actually in the dom where you'd expect.
Then you should be able to add marign-top to the H1 as expected.
I am struggling to make the form on the page fixated to it's current position and doesn't want it to move while scrolling the page. it should be there always at it's current position. the css styling for the form {position: fixed} doesn't work. it makes the whole form disappear from the page. Tried different techniques but none did worked.
even tried giving the form element a {z-index: 1000} but that also didn't helped.
any help would be appreciated.
.rafting-and-camping{
padding-left: 130px;
height: 47px;
width: 724px;
color: #3C4858;
font-family: Roboto;
font-size: 40px;
font-weight: bold;
line-height: 47px;
}
.ganga-river-camp-by {
padding-left: 130px;
height: 48px;
width: 500px;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
line-height: 24px;
}
.stories {
padding-left: 190px;
height: 16px;
width: 63px;
color: #3C4858;
font-family: Roboto;
font-size: 14px;
line-height: 16px;
display: inline;
}
.hours {
padding-left: 78px;
height: 16px;
width: 49px;
color: #8492A6;
font-family: Roboto;
font-size: 14px;
line-height: 16px;
display: inline;
}
.viewed-135-times-tod {
padding-left: 78px;
height: 19px;
width: 171px;
color: #8492A6;
font-family: Roboto;
font-size: 16px;
line-height: 19px;
display: inline;
}
.starts-from-1600 {
padding-left: 420px;
height: 42px;
width: 174px;
color: #3C4858;
font-family: "PingFang SC";
font-size: 16px;
line-height: 22px;
display: inline
}
.mask {
margin-top: 2%;
padding-left: 130px;
height: 500.62px;
width: 1020px;
}
.rectangle-2 {
margin-left: 10%;
height: 90px;
width: 250px;
border: 1px solid #C0CCDA;
display: inline-block;
}
.rectangle-3 {
height: 90px;
width: 250px;
border: 1px solid #C0CCDA;
display: inline-block;
}
.scuba-price {
height: 0.51%;
width: 4.53%;
color: #3C4858;
font-family: "PingFang SC";
font-size: 20px;
font-weight: 500;
line-height: 28px;
}
.bali-scuba-divers {
height: 19px;
width: 123px;
color: #3C4858;
font-family: Roboto;
font-size: 16px;
line-height: 19px;
}
.line-2 {
margin-left: 130px;
box-sizing: border-box;
height: 0.04%;
width: 47.34%;
border: 1px solid #E5E9F2;
}
.what-to-expect {
padding-left: 130px;
padding-top: 20px;
height: 24px;
width: 134px;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
font-weight: 500;
line-height: 24px;
}
.let-s-sail-in-a-rega {
padding-left: 130px;
height: 125px;
width: 600px;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
font-weight: 300;
line-height: 25px;
}
.what-s-included {
padding-left: 130px;
height: 24px;
width: 141px;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
font-weight: 500;
line-height: 24px;
}
.tea-a-vegetarian-l {
padding-left: 130px;
height: 0.44%;
width: 24.77%;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
font-weight: 300;
line-height: 24px;
}
.materials-and-tools {
padding-left: 130px;
height: 71px;
width: 606.29px;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
font-weight: 300;
line-height: 25px;
}
.pre-requisites {
padding-left: 130px;
height: 24px;
width: 124px;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
font-weight: 500;
line-height: 24px;
}
.all-participants-sho {
padding-left: 130px;
height: 23px;
width: 606.29px;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
font-weight: 300;
line-height: 23px;
}
.where-we-ll-meet {
padding-left: 130px;
height: 24px;
width: 153px;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
font-weight: 500;
line-height: 24px;
}
.being-born-in-the-wr {
padding-left: 130px;
height: 161px;
width: 606.29px;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
font-weight: 300;
line-height: 23px;
}
.rectangle-4 {
padding-left: 130px;
height: 6.14%;
width: 47.34%;
}
.contact-operator {
padding-left: 130px;
height: 24px;
width: 154px;
color: #1FB6FF;
font-family: Roboto;
font-size: 20px;
font-weight: 500;
line-height: 24px;
}
.cancellation-and-res {
padding-left: 130px;
height: 0.44%;
width: 25.7%;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
font-weight: 500;
line-height: 24px;
}
.any-trip-or-experien {
padding-left: 130px;
height: 48px;
width: 606.29px;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
font-weight: 300;
line-height: 24px;
}
.notes {
padding-left: 130px;
height: 0.44%;
width: 4.22%;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
font-weight: 500;
line-height: 24px;
}
.we-ll-recommend-you {
padding-left: 130px;
height: 1.32%;
width: 47.37%;
color: #3C4858;
font-family: Roboto;
font-size: 20px;
font-weight: 300;
line-height: 24px;
text-align: justify;
}
/*form style*/
.form {
max-width: 400px;
width: 100%;
margin-top: -95%;
margin-left: 60%;
position: relative;
overflow-y: auto;
}
#contact {
background: #F9F9F9;
padding: 25px;
margin: 150px 0;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
}
#contact h3 {
display: block;
font-size: 30px;
font-weight: 300;
margin-bottom: 10px;
}
fieldset {
border: medium none !important;
margin: 0 0 10px;
min-width: 100%;
padding: 0;
width: 100%;
}
#contact input[type="date"]{
width: 93%;
border: 1px solid #ccc;
background: #FFF;
margin: 0 0 5px;
padding: 10px;
}
#contact select {
width: 100%;
border: 1px solid #ccc;
background: #FFF;
margin: 0 0 5px;
padding: 10px;
}
#contact input[type="date"]:hover,
#contact select {
-webkit-transition: border-color 0.3s ease-in-out;
-moz-transition: border-color 0.3s ease-in-out;
transition: border-color 0.3s ease-in-out;
border: 1px solid #aaa;
}
#contact button[type="submit"] {
cursor: pointer;
width: 100%;
border: none;
background: #4CAF50;
color: #FFF;
margin: 0 0 5px;
padding: 10px;
font-size: 15px;
}
#contact button[type="submit"]:hover {
background: #43A047;
-webkit-transition: background 0.3s ease-in-out;
-moz-transition: background 0.3s ease-in-out;
transition: background-color 0.3s ease-in-out;
}
#contact button[type="submit"]:active {
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}
.rectangle-7 {
height: 57px;
width: 350px;
background-color: #273444;
}
.price {
height: 42px;
width: 87px;
color: #FFFFFF;
font-family: "PingFang SC";
font-size: 30px;
font-weight: 500;
line-height: 42px;
}
/* form end*/
<!DOCTYPE html>
<html lang="en">
<head>
<title>TripShire</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="home.css">
</head>
</script>
<body>
<p class="rafting-and-camping">Rafting and camping by the Ganges</p>
<p class="ganga-river-camp-by"><b>Ganga River .</b> Camp by the river side and raft through the ice cold ganges</p>
<p class="stories">73 Stories</p>
<p class="hours">6 hours</p>
<p class="viewed-135-times-tod">Viewed 135 times today</p>
<p class="starts-from-1600">Starts from ₹1600</p>
<img class="mask" src="rafting.jpg">
<div class="rectangle-2">
<p class="scuba-price">₹1200</p>
<p class="bali-scuba-divers">Bali Scuba Drivers</p>
</div>
<div class="rectangle-3">
<p class="scuba-price">₹2500</p>
<p class="bali-scuba-divers">White Water Tours</p>
</div>
<div class="rectangle-3">
<p class="scuba-price">₹1500</p>
<p class="bali-scuba-divers">Bali Scuba Drivers</p>
</div>
<div class="rectangle-3">
<p class="scuba-price">₹3200</p>
<p class="bali-scuba-divers">Bali Scuba Drivers</p>
</div>
<hr class="line-2">
<h2 class="what-to-expect"><b>What to expect</b></h2>
<p class="let-s-sail-in-a-rega">Let's sail in a regatta sailboat built for a regatta in France and </br> remodeled. The idea is we enjoy Barcelona in a different and </br> adventurous way. We'll experiment the feeling of sailing in a boat that </br> can get high speed. The experience includes a selection of </br> "embutidos"(kind of Catalan meat) specially selected.</p>
<hr class="line-2">
<h2 class="what-s-included"><b>What's included</b></h2>
<h3 class="tea-a-vegetarian-l">Tea and a vegetarian lunch</h3>
<p class="materials-and-tools">Materials and tools </br> Everything will be provided. All animals are ethically sourced and were not killed specially for these workshops</p>
<hr class="line-2">
<h3 class="pre-requisites"><b>Pre requisites</b></h3>
<p class="all-participants-sho">All participants should be greater than 12 years of age</p>
<hr class="line-2">
<h2 class="where-we-ll-meet"><b>Where we'll meet</b></h2>
<p class="being-born-in-the-wr">Being born in the wrong country has always taken a toll on Lauren </br> and Max. With the urge of reliving the golden years, they have been </br> hosting 18th century parties around the world to fill the void. In the </br> real world, Lauren is a fashion stylist and Max works in a video </br> production. </br>
</br>
Address: Terrace Restaurant, Okura Macau, 28F
</p>
<img class="rectangle-4" src="rafting.jpg">
<p class="contact-operator">Contact Operator</p>
<hr class="line-2">
<h2 class="cancellation-and-res"><b>Cancellation and rescheduling policy</b></h2>
<p class="any-trip-or-experien">Any trip or experience can be canceled and fully refunded within 24 </br> hours of purchase.</p>
<hr class="line-2">
<h2 class="notes"><b>Notes</b></h2>
<p class="we-ll-recommend-you">We recommend ypu to get a jumper or something to keep you warm </br> (even in summer). This is a weather-dependent experience. This Experience is subject to sailing and weather conditions.</p>
<!-- Form -->
<div class="container form">
<form id="contact" action="" method="post" >
<h3 class="rectangle-7">₹2500 per person</h3>
<fieldset>
<p>Choose your date</p>
<input type="date" tabindex="1" required autofocus>
</fieldset>
<fieldset>
<p>Guests</p>
<select id="guests" name="guests">
<option value="australia">5 guest</option>
<option value="canada">4 guest</option>
<option value="usa">3 guest</option>
<option value="usa">2 guest</option>
<option value="usa">1 guest</option>
</select>
</fieldset>
<fieldset>
<button name="submit" type="submit" id="contact-submit" data-submit="...Sending">Submit</button>
</fieldset>
</form>
</div>
<!-- form end -->
<script>
window.onscroll = function() {myFunction()};
function myFunction() {
document.getElementById("contact").style.postion = "fixed ";
}
</body>
</html>
Did you set any styles for the position after setting position:fixed?
eg.
#contact {
/* This will position the form in the top, right */
position: fixed;
top: 0;
right: 0;
/*===============================================*/
background: #F9F9F9;
padding: 25px;
margin: 150px 0;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
}
You have set too much margin to .form that it flows out of window
.form {
max-width: 400px;
width: 100%;
/* removed this
margin-top: -95%;
margin-left: 60%;
*/
position: fixed;
top: 0;
left: 0;
overflow-y: auto;
}
form {
margin: 0;
}
I am trying to make a button go underneath a div, however, the button float to the left instead of floating to the right. I am trying to achieve something like this:
So far this is what have:
HTML:
<div class="container">
<div class="main">
<div class="sectiontitle">
<h1 class="maintitle">Free Pick-Up<br>and Delivery</h1>
</div>
<div class="sectiondes">
<p class="maintext"> We offer a free pick up and delivery service to your home or place of work.</p>
</div>
<div class="sectionbutton">
<button href="#!" class="button">learn more</button>
</div>
</div>
</div>
CSS:
.container {
margin-right: auto;
margin-left: auto;
margin-bottom:0px;
}
.main{
margin-top: 100px;
background: url("../img/Home-img.jpg");
height: 931.5px;
width: 1920px;
float: right;
}
.maintitle{
font-family: 'Roboto', sans-serif;
font-weight: 500;
font-size: 65px;
color: #000;
letter-spacing: 2px;
line-height: 60px;
height: 120px;
width: 641.6px;
margin-top: 121px;
margin-right: 392.4px;
margin-left: 886px;
margin-bottom: 30px;
text-align: right;
}
.maintext{
height: 68px;
width: 489.6px;
margin-right: 392.4px;
text-align: right;
float: right;
font-size: 24px;
color: #000;
letter-spacing: 0;
line-height: 34px;
margin-top:0px;
font-family: 'Roboto', sans-serif;
font-weight: 400;
margin-bottom: 30px;
}
.sectionbutton{
float: right;
}
button{
background-color: #1B325F;
font-family: 'Roboto', sans-serif;
font-weight: 700;
border: none;
padding: 13px 28.5px 13px 29px;
float: right;
text-align: center;
text-decoration: none;
border-radius: 2px;
margin-bottom: 20px;
text-transform: uppercase;
font-size: 18px;
color: #ffffff;
letter-spacing: -0.03px;
margin-right: 392.4px;
}
I know for a fact the problem is my CSS but I don't know how to make the button go underneath the other div. The codepen is https://codepen.io/mrsalami/pen/Yxpyop
.container {
margin-right: auto;
margin-left: auto;
margin-bottom:0px;
}
.main{
margin-top: 100px;
background: url("../img/Home-img.jpg");
height: 931.5px;
width: 1920px;
float: right;
}
.maintitle{
font-family: 'Roboto', sans-serif;
font-weight: 500;
font-size: 65px;
color: #000;
letter-spacing: 2px;
line-height: 60px;
height: 120px;
width: 641.6px;
margin-top: 121px;
margin-right: 392.4px;
margin-left: 886px;
margin-bottom: 30px;
text-align: right;
}
.maintext{
height: 68px;
width: 489.6px;
margin-right: 392.4px;
text-align: right;
float: right;
font-size: 24px;
color: #000;
letter-spacing: 0;
line-height: 34px;
margin-top:0px;
font-family: 'Roboto', sans-serif;
font-weight: 400;
margin-bottom: 30px;
}
.sectionbutton{
clear: both;
float: right;
}
button{
background-color: #1B325F;
font-family: 'Roboto', sans-serif;
font-weight: 700;
border: none;
padding: 13px 28.5px 13px 29px;
float: right;
text-align: center;
text-decoration: none;
border-radius: 2px;
margin-bottom: 20px;
text-transform: uppercase;
font-size: 18px;
color: #ffffff;
letter-spacing: -0.03px;
margin-right: 392.4px;
}
<div class="container">
<div class="main">
<div class="sectiontitle">
<h1 class="maintitle">Free Pick-Up<br>and Delivery</h1>
</div>
<div class="sectiondes">
<p class="maintext"> We offer a free pick up and delivery service to your home or place of work.</p>
</div>
<div class="sectionbutton">
<button href="#!" class="button">learn more</button>
</div>
</div>
</div>