Avatar of Joshua Davis
Joshua Davis
 asked on

CSS DIV web page positioning

Hi Everyone,

I am currently working on a small web page challenge as a test for a junior web developer.

I am to build a basic web page (based on the attached mock up). I understand the concept, however it has been along time since i have written in CSS\HTML and last time i did it was common practice to use tables for positioning. I have since learnt that this is no longer correct and I am struggling to get 2 of my components to line up.



The section is an image gallery, which I have already got working and fully interactive, however i cannot get the main image and the sample images to line up as required.

Below is the code I have written, if anyone could help me with the positioning it would be greatly appreciated. (Also if there is anything in there that is bad practice please flag it up)

Thank you,
Josh

<!doctype html>
<html class="no-js" lang="">
    <html>
    <head>
    <link rel="stylesheet"
                href="https://fonts.googleapis.com/css?family=Merriweather">
    <link rel="stylesheet"
                href="https://fonts.googleapis.com/css?family=Baskerville">
    </head>
    </html>

    <body>
<!--[if lte IE 9]>
    <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="https://browsehappy.com/">upgrade your browser</a> to improve your experience and security.</p>
  <![endif]--> 

<!-- Add your site or application content here --> 
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>

.content {
    max-width: 600;
    margin: auto;
    background: white;
    padding: 10px;
}

  .topnav {
    overflow: hidden;
    background-color: #ffffff;
  }
  
  .topnav a {
    float: left;
    color: #000000;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    font-family: Merriweather;
	font-size:10px;
	max-width: 500px;
    margin: auto;
  }
  
  .topnav a:hover {
    background-color: #ddd;
    color: black;
  }
  
  .topnav a.active {
    background-color: #ddd;
    color: black;
  }
  
  .topnav-right {
    float: right;
  }



  
  code {
  background: #ddd;
  border-radius: 6px;
  color: #000000;
  display: block;
  font: 14px/24px "Source Code Pro", Inconsolata, "Lucida Console", Terminal, "Courier New", Courier;
  padding: 24px 15px;
  text-align: center;
}



header,
section,
aside,
footer {
  margin: 0 1.5% 24px 1.5%;
}
section {
    /*float: left;*/
    display: inline-block;
  width: 63%;
}
aside {
  /*float: right;*/
  display: inline-block;
  width: 30%;
}
footer {
  clear: both;
  margin-bottom: 0;
}




.content {
    max-width: 1000px;
    margin: auto;
    background: white;
    padding: 10px;
}
.container {
  position: relative;
}

/* Hide the images by default */
.mySlides {
  display: none;
}
 

.row:after {
  content: "";
  display: table;
  clear: both;
}





.sampleimages {
  float: down;
  width: 25%;
}

.activesample,
.demo:hover {
border: 3px solid #FAEA20; 
} 

.square{
    width: 600px;
    height: 700px;
    padding-top: 30px;
    padding-left: 50px;
    Background-color: #FAEA20;
}



  </style>
<div class="content">
      <header>
    <div class="topnav"> <a class="active" href="#home">Home</a> <a href="#men">Men</a> <a href="#women">Women</a> <a href="#Style_Accessories">Style & Accessories</a> <a  href="#logo_home"><img src="Images/Logo.png" width="57" height="57" alt="Logo"></a>
          <div class="topnav-right"> <a href="#myaccount">My Account</a> <a href="#saveditems">Saved Items</a> <a href="#mybasket"><img src="Images/BasketImage.png" width="69" height="57" alt="Basket"></a> </div>
        </div>
  </header>
      <section>
    <div class="mySlides">
          <div class="square"> <img src="Images/Prod1_1.png" style="width:120%;"> </div>
        </div>
    <div class="mySlides">
          <div class="square"> <img src="Images/Prod1_2.png" style="width:120%"> </div>
        </div>
    <div class="mySlides">
          <div class="square"> <img src="Images/Prod1_3.png" style="width:120%"> </div>
        </div>
    <div class="mySlides">
          <div class="square"> <img src="Images/Prod1_4.png" style="width:120%;"> </div>
        </div>
    <div class="mySlides">
          <div class="square"> <img src="Images/Prod1_5.png" style="width:120%"> </div>
        </div>
    <div class="mySlides">
          <div class="square"> <img src="Images/Prod1_6.png" style="width:120%"> </div>
        </div>
  </section>
      <aside>
    <div class="sampleimages"> <img class="demo cursor" src="Images/Prod1_1.png" style="width:100%" onclick="currentSlide(1)" > </div>
    <div class="sampleimages"> <img class="demo cursor" src="Images/Prod1_2.png" style="width:100%" onclick="currentSlide(2)" > </div>
    <div class="sampleimages"> <img class="demo cursor" src="Images/Prod1_3.png" style="width:100%" onclick="currentSlide(3)" > </div>
    <div class="sampleimages"> <img class="demo cursor" src="Images/Prod1_4.png" style="width:100%" onclick="currentSlide(4)" > </div>
    <div class="sampleimages"> <img class="demo cursor" src="Images/Prod1_5.png" style="width:100%" onclick="currentSlide(5)" > </div>
    <div class="sampleimages"> <img class="demo cursor" src="Images/Prod1_6.png" style="width:100%" onclick="currentSlide(6)" > </div>
  </aside>
      <footer> <code>&#60;footer&#62;</code> </footer>
    </div>
</body>
    </html><script>

    var slideIndex = 1;
    showSlides(slideIndex);
    
    function currentSlide(n) {
      showSlides(slideIndex = n);
    }
    
    function showSlides(n) {
      var i;
      var slides = document.getElementsByClassName("mySlides");
      var dots = document.getElementsByClassName("sampleimages");
      if (n > slides.length) {slideIndex = 1}
      if (n < 1) {slideIndex = slides.length}
      for (i = 0; i < slides.length; i++) {
          slides[i].style.display = "none";
      }
      for (i = 0; i < dots.length; i++) {
          dots[i].className = dots[i].className.replace(" activesample", "");
      }
      slides[slideIndex-1].style.display = "block";
      dots[slideIndex-1].className += " activesample";
      captionText.innerHTML = dots[slideIndex-1].alt;
    }
    </script>

Open in new window

CSSHTML

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Julian Hansen

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Joshua Davis

ASKER
Thanks for your help! It took a bit of playing around but I got it to work.
Julian Hansen

You are welcome.
Joshua Davis

ASKER
Hi,

I have continued to work on this and its a bit further along, but i have come to a similar issue with positioning.
I am just trying to get my head round how the different positioning and flex methods work.

The section I am currently working on is the order form on the page. I have attached all of my code this time.Web-Challenge-Site---Copy.zip

If you could offer any advise it would be appreciated.

Thank you again,
Josh
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Joshua Davis

ASKER
Hi,

I have continued to work on this and its a bit further along, but i have come to a similar issue with positioning.
I am just trying to get my head round how the different positioning and flex methods work.

The section I am currently working on is the order form on the page. I have attached all of my code this time.

If you could offer any advise it would be appreciated.

Thank you again,
Josh
Julian Hansen

Best to open another question for this. Refer to this one and post the link to the new question here.