Here is the mini-project I’m building:
https://www.frontendmentor.io/challenges/article-preview-component-dYBN_pYFT
I’m on the mobile design section.
Here is my code so far (mine looks a lot better, but I can’t upload images to CodePen without buying PRO):
When you scale down to mobile size and click the circular icon, the blue section at the bottom appears. The problem is when you move it to a larger size, the section with the name, date etc. doesn’t appear.
These are the important parts to look at:
@media screen and (min-width: 521px) {
#hide-and-show {
display: none;
}
#hide-and-show div {
display: none;
}
#personal-container {
display: flex;
}
}
<div class="personal-container" id="personal-contain">
<div class="personal-container-img-text" id="hide-section">
<div>
<img id="avatar-img" src="images/avatar-michelle.jpg"/>
</div>
<div class="name-date">
<p id="name-section"><span id="personal-name">Michelle Appleton</span><br>
<span id="personal-date">28 Jun 2020</span></p>
</div>
</div>
<div class="share-icon-container" id="hide-share-section">
<div id="share-icon" class="popup" onclick="myFunction();" onmouseover="onHover();" onmouseout="offHover();">
<img id="icon-share" src="images/icon-share.svg"/>
<div class="popuptext bubble-container" id="myPopup">
<div><p>SHARE</p></div>
<div><a class="social-icon" href="https://www.facebook.com/"><img src="images/icon-facebook.svg"/></a></div>
<div><a class="social-icon" href="https://twitter.com/"><img src="images/icon-twitter.svg"/></a></div>
<div><a class="social-icon" href="https://www.pinterest.com/"><img src="images/icon-pinterest.svg"/></a></div>
</div>
</div>
</div>
</div>
</div>
<div id="hide-and-show">
<div><p>SHARE</p></div>
<div><a href="https://www.facebook.com/"><img src="images/icon-facebook.svg"/></a></div>
<div><a href="https://twitter.com/"><img src="images/icon-twitter.svg"/></a></div>
<div><a href="https://www.pinterest.com/"><img src="images/icon-pinterest.svg"/></a></div>
<div id="share-icon" class="popup" onclick="myFunctionTwo();" onmouseover="onHover();" onmouseout="offHover();">
<img id="icon-share" src="images/icon-share.svg"/>
</div>
</div>
</div>
</div>
<script>
function onHover()
{
$('#icon-share').attr('src', 'images/icon-share-white.svg');
}
function offHover()
{
$('#icon-share').attr('src', 'images/icon-share.svg');
}
function myFunction() {
var x = window.matchMedia("(max-width: 520px)")
if (x.matches) { // If media query matches
//hide-share-section
document.getElementById("personal-contain").style.display = "none";
document.getElementById("hide-and-show").style.display = "flex";
} else {
var popup = document.getElementById("myPopup");
popup.classList.toggle("show");
}
}
function myFunctionTwo() {
document.getElementById("hide-and-show").style.display = "none";
document.getElementById("personal-contain").style.display = "flex";
}
</script>
Does anyone know why this is happening? In the media query, I set #personal-container to flex once it gets to certain size, so I thought it should appear again.