Reputation: 83527
I am working through a Udacity course on JavaScript. The main project is a resume built from a basic skeleton that the instructors provide as a GitHub repo. Here is a screenshot of my most recent version:
As you can see, my skills list moves to the left after it reaches the bottom of my picture. I want to keep the entire bulleted list lined up with the first two list items. How do I do this? Is it possible with the right <div>
s or do I need a <table>
?
Below is the relevant code:
index.html
<html>
<head>
<meta charset="utf-8">
<title>Resume</title>
<link href="css/style.css" rel="stylesheet">
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<div id="main">
<div id="header" class="center-content clear-fix">
<ul id="topContacts" class="flex-box"></ul>
</div>
<div style="clear: both;"></div>
<div id="workExperience" class="gray">
<h2>Work Experience</h2>
</div>
<div id="projects">
<h2>Projects</h2>
</div>
<div id="education" class="gray">
<h2>Education</h2>
</div>
<div id="mapDiv">
<h2>Where I've Lived and Worked</h2>
</div>
<div id="lets-connect" class="dark-gray">
<h2 class="orange center-text">Let's Connect</h2>
<ul id="footerContacts" class="flex-box">
</ul>
</div>
</div>
<script src="js/jQuery.js"></script>
<script src="js/helper.js"></script>
<script src="js/resumeBuilder.js"></script>
<script>
if(document.getElementsByClassName('flex-item').length === 0) {
document.getElementById('topContacts').style.display = 'none';
}
if(document.getElementsByTagName('h1').length === 0) {
document.getElementById('header').style.display = 'none';
}
if(document.getElementsByClassName('work-entry').length === 0) {
document.getElementById('workExperience').style.display = 'none';
}
if(document.getElementsByClassName('project-entry').length === 0) {
document.getElementById('projects').style.display = 'none';
}
if(document.getElementsByClassName('education-entry').length === 0) {
document.getElementById('education').style.display = 'none';
}
if(document.getElementsByClassName('flex-item').length === 0) {
document.getElementById('lets-connect').style.display = 'none';
}
if(document.getElementById('map') === null) {
document.getElementById('mapDiv').style.display = 'none';
}
</script>
</body>
</html>
js/resumeBuilder.js
var dataPlaceHolder = "%data%";
var bio = {
"name" : "Code Apprentice",
"role" : "Software Engineer",
"contact" : {
"phone" : "555-555-5555",
"email" : "[email protected]",
"twitter" : "@codeguru42",
"github" : "codeguru42",
"location" : "Code Heaven"
},
"pictureURL" : "images/minion-me.png",
"welcomeMessage" : "Android Developer | Stack Overflow Contributor | Full Stack Web Developer",
"skills" : ["Java", "C++", "Android Development", "HTML", "JavaScript", "CSS", "Python"]
};
var formattedName = HTMLheaderName.replace(dataPlaceHolder, bio.name);
var formattedRole = HTMLheaderRole.replace(dataPlaceHolder, bio.role);
var formattedPhone = HTMLmobile.replace(dataPlaceHolder, bio.contact.phone);
var formattedEmail = HTMLemail.replace(dataPlaceHolder, bio.contact.email);
var formattedTwitter = HTMLtwitter.replace(dataPlaceHolder, bio.contact.twitter);
var formattedGithub = HTMLgithub.replace(dataPlaceHolder, bio.contact.github);var formattedPicture = HTMLbioPic.replace(dataPlaceHolder, bio.pictureURL);
var formattedLocation = HTMLlocation.replace(dataPlaceHolder, bio.contact.location);
var formattedBioPic = HTMLbioPic.replace(dataPlaceHolder, bio.pictureURL);
var formattedWelcomeMessage = HTMLwelcomeMsg.replace(dataPlaceHolder, bio.welcomeMessage);
var formattedSkills = bio.skills.map(function (skill) { return HTMLskills.replace(dataPlaceHolder, skill); });
$("#header").prepend(formattedRole);
$("#header").prepend(formattedName);
$("#header").prepend(formattedBioPic);
$("#header").append(formattedWelcomeMessage);
$("#header").append(HTMLskillsStart);
$("#header").append(formattedSkills);
$("#topContacts").append(formattedPhone);
$("#topContacts").append(formattedEmail);
$("#topContacts").append(formattedLocation);
$("#footerContacts").append(formattedTwitter);
$("#footerContacts").append(formattedGithub);
css/styles.css
body,
div,
ul,
li,
p,
h1,
h2,
h3,
h4,
h5,
h6 {
padding: 0;
margin: 0;
font-family: "Roboto", sans-serif;
}
.clear-fix {
overflow: auto;
}
.education-entry,
.work-entry,
.project-entry {
padding: 0 5%;
}
h1 {
font-size: 40px;
color: #f5a623;
line-height: 48px;
display: inline;
}
h2 {
font-weight: bold;
font-size: 24px;
color: #999;
line-height: 29px;
padding: 10px;
}
h3 {
font-style: italic;
font-size: 20px;
color: #000;
line-height: 22px;
}
h4 {
font-weight: bold;
font-size: 14px;
color: #4a4a4a;
line-height: 17px;
}
h2,
h3,
h4,
h5 {
padding: 10px 5%;
}
.date-text {
font-style: italic;
font-size: 14px;
color: #999;
line-height: 16px;
float: left;
}
.location-text {
font-style: italic;
font-size: 14px;
color: #999;
line-height: 16px;
float: right;
}
p {
font-size: 14px;
color: #333;
line-height: 21px;
}
a {
color: #1199c3;
text-decoration: none;
margin-top: 10px;
display: block;
}
.welcome-message {
font-style: italic;
font-size: 18px;
color: #f3f3f3;
line-height: 28px;
}
#skills-h3 {
color: #f5ae23;
display: none;
}
.orange {
background-color: #f5ae23;
}
.orange-text {
color: #f5ae23;
}
.white-text {
font-weight: bold;
color: #fff;
}
.gray {
background-color: #f3f3f3;
padding-bottom: 10px;
clear: both;
}
.dark-gray {
background-color: #4a4a4a;
}
/* TODO: Replace with image later */
#header {
background-color: #484848;
}
.flex-box {
display: -webkit-flex;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
padding: 10px;
}
.flex-column {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
padding: 10px;
}
.center-content {
padding: 2.5% 5%;
}
ul {
list-style-type: none;
}
.biopic {
float: left;
padding: 10px;
width: 200px;
display: none;
}
img {
padding: 10px;
}
span {
padding: 5px;
}
#lets-connect {
text-align: center;
}
/* Media queries to handle various device widths */
@media only screen and (max-width: 1024px) {
#lets-connect {
margin-top: 5%;
}
}
@media only screen and (max-width:900px) {
.biopic {
width: 175px;
}
}
@media only screen and (max-width: 750px) {
#lets-connect {
margin-top: 10%;
}
.biopic {
width: 150px;
}
.welcome-message {
display: none;
}
}
#map {
display: block;
height: 100%;
margin: 0 5%;
}
#mapDiv {
height: 400px;
width: 100%;
padding-bottom: 5%;
}
@media only screen and (min-width: 750px) {
#skills-h3,
.biopic {
display: block;
}
}
js/helper.js
var HTMLheaderName = '<h1 id="name">%data%</h1>';
var HTMLheaderRole = '<span>%data%</span><hr>';
var HTMLcontactGeneric = '<li class="flex-item"><span class="orange-text">%contact%</span><span class="white-text">%data%</span></li>';
var HTMLmobile = '<li class="flex-item"><span class="orange-text">mobile</span><span class="white-text">%data%</span></li>';
var HTMLemail = '<li class="flex-item"><span class="orange-text">email</span><span class="white-text">%data%</span></li>';
var HTMLtwitter = '<li class="flex-item"><span class="orange-text">twitter</span><span class="white-text">%data%</span></li>';
var HTMLgithub = '<li class="flex-item"><span class="orange-text">github</span><span class="white-text">%data%</span></li>';
var HTMLblog = '<li class="flex-item"><span class="orange-text">blog</span><span class="white-text">%data%</span></li>';
var HTMLlocation = '<li class="flex-item"><span class="orange-text">location</span><span class="white-text">%data%</span></li>';
var HTMLbioPic = '<img src="%data%" class="biopic">';
var HTMLwelcomeMsg = '<span class="welcome-message">%data%</span>';
var HTMLskillsStart = '<h3 id="skills-h3">Skills at a Glance:</h3><ul id="skills" class="flex-column"></ul>';
var HTMLskills = '<li class="flex-item"><span class="white-text">%data%</span></li>';
Upvotes: 2
Views: 53
Reputation: 83527
After Inspecting the HTML elements in the generated page, I found that I was not correctly inserting <li>
tags for each skill into the <ul>
tag defined in HTMLskillsStart
. I just had to change
$("#header").append(formattedSkills);
to
$("#skills").append(formattedSkills);
Upvotes: 1
Reputation: 519
Try to give clear:both
to the image tag, so that the list does not move under the bottom of the picture.
Upvotes: 1