We help IT Professionals succeed at work.

CSS DIV web page positioning

Joshua Davis
Joshua Davis asked
on
123 Views
Last Modified: 2018-09-16
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

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Joshua DavisIT Technician

Author

Commented:
Thanks for your help! It took a bit of playing around but I got it to work.
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

Commented:
You are welcome.
Joshua DavisIT Technician

Author

Commented:
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
Joshua DavisIT Technician

Author

Commented:
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
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

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

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions