I’m having an issue where all of the separate links to the codepens stopped triggering on click of button except for the last one, which works fine. Anybody know what could be causing this? https://studiosemantica.com is where the live site is, and also including my code.
I have tried moving the .attr('href', project.url)
to the second tag , removing the button and replacing it with just , tryied doubling up on the .attr('href', project.url)
by adding to the second , all to no avail. I'm not sure if this is an issue that can be cause by CSS styling?
JAVASCRIPT/jQuery CODE
// all application logic is included inside the app() function
const app = (projects) => {
// creates a jQuery DOM element based on an individual project object
const createProjectElement = (project) => {
const $div = $('<div>').addClass("project")
const $divOverlay = $('<div>').addClass("overlay")
const $overlayText = $('<div>').addClass("overlayText").append($('<h2>').text(project.title))
const $imageDiv = $('<div>').addClass("imageDiv").append($('<img>').attr('src', project.image))
// $div.append($('<h2>').text(project.title))
$div.append($($divOverlay).append($($overlayText).append($($imageDiv))))
$div.append($('<p>').addClass("description").text(project.description))
$div.append($('<button>').append($('<a>').addClass("list-group-item").attr('href', project.url).append($('<i>').addClass("fa fa-codepen").append($('<a>').addClass("small").text('Live Demo')))))
return $div
}
// adds each project element to <body>
projects.forEach(project => {
const $projectDiv = createProjectElement(project)
$('body').append($projectDiv)
})
}
CSS
.project {
display:flex;
flex-direction:column;
text-align:center;
margin:35px auto auto auto;
border:2px solid black;
width:250px;
height:360px;
background-color:white;
}
.overlay {
display:flex;
flex-direction:column;
justify-content:space-around;
z-index:999;
width:250px;
margin-bottom:130px;
margin-top:0px;
background-color:white;
height:90px;
}
.imageDiv {
position:relative;
width:100%;
z-index:-1;
}
h2 {
position:relative;
text-align:center;
font-family:"Pragati Narrow";
background-color:rgba(000, 000, 000, 0.2);
padding-top:60px;
padding-bottom:60px;
color:white;
z-index:999;
top:190px;
left:0 auto;
width:100%;
}
img {
width: 250px;
height:160px;
margin:10px auto;
}
button {
background-color:rgba(000, 000, 000, 0.2);
width:150px;
display:flex;
flex-direction:row;
justify-content:space-around;
border-style:none;
border-radius:5px;
margin:15px auto;
margin-top:5px;
padding:6px;
}
.list-group-item {
text-align:left;
width:150px;
font-size:25px;
color:dimgrey;
margin-left:25px;
}
.small {
position:absolute;
font-family:"Pragati Narrow";
font-size:15px;
margin-left:6px;
margin-bottom:30px;
margin-top:-5px;
padding:10px 0px 20px 0px;
}