The 3 blog posts on this page are no longer stacking (responsive) on mobile. Can someone help me adjust this so the blog post snippets stack on top of each other on mobile? I need it to be responsive on mobile! Also, if you would recommend a way to add a "Read More" link at the bottom of each excerpt that takes users to the blog page.
[![blog posts not stacking][1]][1]
Here is the CSS and you will find the HTML below.
.blog-list {
padding: 0 8px;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
.blog-list li {
padding-bottom: 20px;
}
.blog-list a {
position: relative;
text-decoration: none;
height: 400px;
}
.blog-list img {
display: block;
height: auto !important;
width: 100%;
}
#media only screen and (min-width: 700px) {
.blog-list {
display: grid;
grid-column-gap: 20px;
grid-template-columns: 1fr 1fr 1fr;
}
}
#media only screen and (min-width: 980px) {
.blog-list {
padding-bottom: 25px;
}
.blog-list h3 {
font-size: 2.4rem;
}
.blog-list a {
display: block;
}
.blog-list a img {
transition: ease all .5s;
}
.blog-list a:hover {
opacity: .8;
}
.blog-list + footer {
padding-bottom: 100px;
}
}
<section class="generic">
<div class="inner">
<ul class="blog-list">
<li>
<a href="https://bluestoneconstruction.com/asheville-nc-the-best-place-to-live-if-you-can-live-anywhere/">
<img src="https://bluestoneconst.wpengine.com/wp-content/uploads/2018/11/liveable-cities-where-to-move-if-you-can-live-anywhere-6.jpg" alt="">
<h3>Asheville, NC: The Best Place To Live If You Can Live Anywhere</h3>
</a>
<p>Experienced travelers know the best place to eat in Chicago, the best hotel to stay at in New York, the best place to watch the sunset over the Rocky Mountains, the best beach on the East Coast — you get the picture. But what about moving somewhere new? This requires a different set of criteria. Vacation</p>
</li>
<li>
<a href="https://bluestoneconstruction.com/luxury-mens-brand-chooses-bluestone-home-for-fall-catalog-photo-shoot/">
<img width="920" height="690" src="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-920x690.jpg" class="img-responsive wp-post-image" alt="" loading="lazy" srcset="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-920x690.jpg 920w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-300x225.jpg 300w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-768x576.jpg 768w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction.jpg 1024w" sizes="(max-width: 920px) 100vw, 920px">
<h3>Luxury Men’s brand chooses Bluestone custom home for Fall catalog photo shoot</h3>
</a>
<p>After a 4 day photo shoot with luxury fashion brand Peter Millar at our client’s rustic custom home for their fall/ holiday luxury men’s apparel catalog, we got some fun aerial and ground shots of our own thanks to Carl Amoth. Very impressive to see what goes into all of the amazing photographs a brand</p>
</li>
<li>
<a href="https://bluestoneconstruction.com/2020-master-design-award-winner/">
<img width="921" height="690" src="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-921x690.jpg" class="img-responsive wp-post-image" alt="" loading="lazy" srcset="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-921x690.jpg 921w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-300x225.jpg 300w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-1024x767.jpg 1024w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-768x576.jpg 768w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-1536x1151.jpg 1536w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8.jpg 1600w" sizes="(max-width: 921px) 100vw, 921px">
<h3>2020 Master Design Award Winner for Best Outdoor Environment</h3>
</a>
<p>We are so delighted to win another award for this stunning custom home in Fairview, North Carolina. The work we do represents the best of the best in design, materials, and talent. We thank everyone who helped put this project together. It is always a collaborative creative process that leaves us grateful and satisfied standing</p>
</li>
</ul>
</div>
</section>
[1]: https://i.stack.imgur.com/n4jOn.png
Use display: flex on .blog-list instead of display: grid and then add a media query at about 550px and change the flex direction to column:
body {
margin: 0;
}
.blog-list {
display: flex;
margin: 0;
padding: 0;
}
.blog-list li {
padding: 10px;
list-style-type: none;
}
.blog-list a {
position: relative;
text-decoration: none;
}
.blog-list img {
display: block;
height: auto !important;
width: 100%;
}
#media only screen and (max-width: 550px) {
.blog-list {
flex-direction: column;
}
}
#media only screen and (min-width: 980px) {
.blog-list h3 {
font-size: 2.4rem;
}
.blog-list a img {
transition: ease all 0.5s;
}
.blog-list a:hover {
opacity: .8;
}
.blog-list + footer {
padding-bottom: 100px;
}
}
<section class="generic">
<div class="inner">
<ul class="blog-list">
<li>
<a href="https://bluestoneconstruction.com/asheville-nc-the-best-place-to-live-if-you-can-live-anywhere/">
<img src="https://bluestoneconst.wpengine.com/wp-content/uploads/2018/11/liveable-cities-where-to-move-if-you-can-live-anywhere-6.jpg" alt="">
<h3>Asheville, NC: The Best Place To Live If You Can Live Anywhere</h3>
</a>
<p>Experienced travelers know the best place to eat in Chicago, the best hotel to stay at in New York, the best place to watch the sunset over the Rocky Mountains, the best beach on the East Coast — you get the picture. But what about moving somewhere new? This requires a different set of criteria. Vacation</p>
</li>
<li>
<a href="https://bluestoneconstruction.com/luxury-mens-brand-chooses-bluestone-home-for-fall-catalog-photo-shoot/">
<img width="920" height="690" src="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-920x690.jpg" class="img-responsive wp-post-image" alt="" loading="lazy" srcset="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-920x690.jpg 920w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-300x225.jpg 300w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-768x576.jpg 768w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction.jpg 1024w" sizes="(max-width: 920px) 100vw, 920px">
<h3>Luxury Men’s brand chooses Bluestone custom home for Fall catalog photo shoot</h3>
</a>
<p>After a 4 day photo shoot with luxury fashion brand Peter Millar at our client’s rustic custom home for their fall/ holiday luxury men’s apparel catalog, we got some fun aerial and ground shots of our own thanks to Carl Amoth. Very impressive to see what goes into all of the amazing photographs a brand</p>
</li>
<li>
<a href="https://bluestoneconstruction.com/2020-master-design-award-winner/">
<img width="921" height="690" src="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-921x690.jpg" class="img-responsive wp-post-image" alt="" loading="lazy" srcset="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-921x690.jpg 921w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-300x225.jpg 300w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-1024x767.jpg 1024w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-768x576.jpg 768w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-1536x1151.jpg 1536w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8.jpg 1600w" sizes="(max-width: 921px) 100vw, 921px">
<h3>2020 Master Design Award Winner for Best Outdoor Environment</h3>
</a>
<p>We are so delighted to win another award for this stunning custom home in Fairview, North Carolina. The work we do represents the best of the best in design, materials, and talent. We thank everyone who helped put this project together. It is always a collaborative creative process that leaves us grateful and satisfied standing</p>
</li>
</ul>
</div>
</section>
Here's a link to my Codepen: https://codepen.io/ajarrow/pen/oNxmxGr
EDIT
After looking at your website, it looks like there is a media query with a min-width of 700px (any device with a screen width of greater than 700px, which would be a vary large phone) which is handling the .blog-list element. Under that width, the blog-list element no longer has a grid-column-gap defined and the columns are still set to three columns. So if you add a simple media query like below, it should work as expected:
#media only screen and (max-width: 700px) {
.blog-list {
display: grid;
grid-template-columns: 1fr;
padding: 0 8px;
}
}
Also, some other things I noticed while on your website:
The div with an id of site-frame has a margin-bottom of 515 px to allow the location/contact info at the bottom to be seen when the user scrolls to the bottom of the page. That's cool, except that the margin isn't removed when the location/contact info is moved inside the site-frame at 760px. Yep, you guessed it...add another media query with a max-width of 760px:
#media only screen and (max-width: 760px) {
#site-frame {
margin-bottom: 0 !important;
}
}
And you have to use !important because the original margin is inline, which will override anything else unless you use !important.
And then the images in the 'Featured Projects' directly above the 'News' section were being stretched and shrunk/overlapped by their parent element. After a bunch of head-scratching, I fixed the problem with this CSS:
.project-list a img {
max-height: 100%;
object-fit: contain;
max-width: 100% !important;
}
Those are just some things I noticed, you can do what you want. Also, I still didn't see the CSS I gave you the other day...did you remove it or is it not coming through? It looked like you were using WP...to add custom css, log in to the backend of your site and when you're viewing the front page of your site, hit the 'Customize' button (paintbrush icon on mobile) in the header bar at the top. Scroll to the bottom, select 'Additional CSS', and paste the code box on the left. Let me know the results!
EDIT
A very simple way to add 'Read More' buttons would be to borrow the styling from the class special-button (which is being used on the 'Meet With Us' button directly below the posts) with an a element:
Read More
You would have to add this to the bottom of each post and change the href attribute manually. A more dynamic way to do it would be to add this bit of javascript AFTER the blog posts:
<script>
document.querySelectorAll('.blog-list li a').forEach(function(item) {
var newA = document.createElement('a');
newA.href = item.href;
newA.classList = 'special-button';
newA.textContent = 'Read More';
item.parentElement.insertAdjacentElement('beforeend', newA);
});
</script>
Related
sorry in advance for my english,
I have to reproduce this original
But I do this : my solution
Here it's my code :
div.psp div.picture-left img {
width: 45%;
margin-right: 1em;
float:left;
}
div.psp div.picture-left figure figcaption {
font-size: .7em;
}
<h2>Put some pictures</h2>
<div class="psp">
<div class="picture-left">
<figure>
<img src="images/cat.jpg" title="A nice and cute cat" alt="white and gray cat looking at you, with his yellow and green eyes" />
<figcaption>A cat, just to keep the context of the website.</figcaption>
</figure>
</div>
<div class="tleft">
<p>
We're not looking at a novel by Stephenie Meyer, this is a <span class="mfw">motherfuckingwebsite</span>.
Add some relevant pictures to give a little bit of context, or to cheer up the reader.
Do you really like to waste the power of technology that we have nowadays? Come on, you're using a
web browser on a computer, you're not reading a book on a Kindle.
</p>
<p>The website shouldn't be overfilled with pictures, but it should make the user happy while reading your nonsense words.</p>
<p>You see the picture of this cute cate? He's happy, and you should be too.</p>
</div>
</div>
I dont know why my figcaption move like that.
I thank you in advance.
change your IMG Style Like this
div.psp div.picture-left img {
width: 100%;
margin-right: 1em;
float:left;
}
then add css class .picture-left
like this
.picture-left {
width:45%;
}
then add CSS class .psp like this
.psp{
display: flex;
}
try this if you have any doubt comment me
and don't use bad words on public platform posts✌
div.psp div.picture-left img {
width: 100%;
margin-right: 1em;
float:left;
}
.picture-left {
width:45%;
}
.psp{
display: flex;
}
div.psp div.picture-left figure figcaption {
font-size: .7em;
}
<h2>Put some pictures</h2>
<div class="psp">
<div class="picture-left">
<figure>
<img src="https://images.pexels.com/photos/104827/cat-pet-animal-domestic-104827.jpeg" title="A nice and cute cat" alt="white and gray cat looking at you, with his yellow and green eyes" />
<figcaption>A cat, just to keep the context of the website.</figcaption>
</figure>
</div>
<div class="picture-left">
<p>
We're not looking at a novel by Stephenie Meyer, this is a <span class="mfw">motherfuckingwebsite</span>.
Add some relevant pictures to give a little bit of context, or to cheer up the reader.
Do you really like to waste the power of technology that we have nowadays? Come on, you're using a
web browser on a computer, you're not reading a book on a Kindle.
</p>
<p>The website shouldn't be overfilled with pictures, but it should make the user happy while reading your nonsense words.</p>
<p>You see the picture of this cute cate? He's happy, and you should be too.</p>
</div>
</div>
It happned because you floated the image to left.
Thats why it is going on the side.
Just don't select the img tag, Like this:
div.psp div.picture-left { /* <---- Just remove the img */
width: 45%;
margin-right: 1em;
float:left;
}
div.psp div.picture-left figure figcaption {
font-size: .7em;
}
I've recently started learning web dev. I'm making a site that fetches data from the mealdb api and displays the data. I've mostly gotten everything working, but the issue is when I inspect the web page and view it on mobile, the image is rendered on top of the text, i.e. the title and the ingredients. How do I prevent this from happening?
Ideally, on a mobile device, I'd like to show the title, followed by the image, ingredients and the instructions in a single column.
This is how it looks on desktop:
On mobile:
.Recipe {
padding-top: 30px;
text-align: left;
display: flex;
flex-wrap: wrap;
justify-content: center;
overflow: auto;
vertical-align: text-top;
}
.left-content {
width: 40%;
float: left;
}
.list {
list-style: none;
padding-left: 0px;
padding-bottom: 15px;
font-size: 1.2rem;
}
.right-content {
width: 40%;
float: right;
}
.title {
font-size: 3rem;
justify-content: center;
padding-bottom: 0px;
}
.instructions {
font-size: 1.2rem;
}
.Recipe h1 {
text-align: center;
padding-left: 250px;
}
.image {
float: right;
height: 480px;
width: 480px;
margin: 20px
}
<div className="Recipe">
<div className="left-content">
<h2 className="title">{prop.food.meals[0].strMeal}</h2>
<ul className="list">
{prop.materials.map(function(ingredients){ return
<li key={ingredients.strIngredient}>{ingredients.name + " - " + ingredients.amount}</li>
})}
</ul>
<p className="instructions">{prop.food.meals[0].strInstructions}</p>
</div>
<div className="right-content">
<img src={prop.food.meals[0].strMealThumb} alt="" className="image" />
</div>
</div>
This is a CSS situation, and for this specific situation I highly suggest learning about grid: https://css-tricks.com/snippets/css/complete-guide-grid/
Now, I know you probably don't want to read that much or learn something entirely new just to solve this. So for now I will give you a quick solution, which it isn't so bad in terms of performance.
You can use react-device-detect
It has some components that print specifically on Desktop or Mobile. So in your case you can have something like this:
import {BrowserView, MobileView} from 'react-device-detect';
And in your render:
<div className="Recipe">
<div className="left-content">
<h2 className="title">{prop.food.meals[0].strMeal}</h2>
<MobileView>
<img src={prop.food.meals[0].strMealThumb} alt="" className="image"/>
</MobileView>
<ul className="list">
{prop.materials.map(function(ingredients){
return <li key={ingredients.strIngredient}>{ingredients.name + " - " + ingredients.amount}</li>
})}
</ul>
<p className="instructions">{prop.food.meals[0].strInstructions}</p>
</div>
<BrowserView>
<div className="right-content">
<img src={prop.food.meals[0].strMealThumb} alt="" className="image"/>
</div>
</BrowserView>
</div>
The idea is printing the image "twice", one for mobile and one for desktop. However, they will not be printed at the same time, obviously. And the images on web get requested only once, so you can print the same image dozens of time but it will only be loaded once on the browser, which is why this alternate solution works well.
If you don't want to use react-device-detect, you can print the image twice (on the same location as the example), and on CSS just use Media Query to set a display: none for mobile and desktop when they're not required. Let me know if you prefer CSS and I can elaborate further on how to do this on CSS. But I don't suggest this one because it is less efficient since the HTML will have two tags of the same image even if you're hiding them on CSS.
Let me know if you have any questions. And I hope this was helpful.
What I want to do is make my sidebar cards be on the right and not the left. I've tried to use the display: grid; and that didn't work. I've tried to use the left: 0; and right: 0; in css. Nothing is working for me. My full code is at github.com.
Please ingnore the colors, I tried to draw it in google drawings so it's not good.
This is how it is:
And this is how I want it to look:
You could use a grid like this. For detail explanations check here
*,
:before,
:after {
box-sizing: border-box;
}
body {
display: grid;
grid-gap: 10px;
grid-template-columns: 60% 40%;
grid-template-areas: "header header" "content cards";
width: 100%;
}
#header {
grid-area: header;
}
#content {
grid-area: content;
}
#cards {
grid-area: cards;
}
<h3 id="header">Welcome to my GitHub Pages website this is where you can learn about me, find my games, and suggest ideas for anything!</h3>
<div id="content">
</div>
<div id="cards" class="cards">
<div id="project1" class="project-card">
<h1>
Web Designer Tycoon
</h1>
<p>This is a idle tycoon like game where you have to make money by making web programs. People buy your web programs for money. If you get better at coding (in the game) then you will get more money for each program you make. Itis currently in the BETA
stage and it will get released after lots of testing and a couple more changes. Thank you for your patience. <span onclick="window.location.href = 'https://codepen.io/hacker19374/project/full/Zyraey/'">Click me to go to Web Designer Tycoon</span></p>
</div>
<div id="project2" class="project-card">
<h1>
Burger Clicker
</h1>
<p>This game is a little bit different. It is a clicker game where you clic and click and click over and over to try to get the most money you can and you can use that money to buy</p>
</div>
</div>
There are multiple ways to achieve this. But since you are using css grid do the following:
Add an extra class of project-card__1 and project-card__2 to the cards and then specify the grid-template-columns in your css.
See the demo below
p {
background-color: #179595;
width: auto;
}
.project-card {
margin: 5px;
width: 25%;
border: 4px solid #00688b;
background-color: #008b8b;
height: 354.33px;
margin-bottom: 50px;
margin-right: 50px;
}
h1 {
text-align: center;
padding-top: 5px;
}
body {
background-image: linear-gradient(270deg, #8b0046, #8b008b);
height: 100vh;
}
span {
cursor: ;
}
.cards {
display: grid;
grid-template-columns: repeat(6, 1fr);
right: 0;
}
.project-card__1 {
grid-column: 5 / 7;
grid-row: 1;
width: 100%;
}
.project-card__2 {
grid-column: 5 / 7;
grid-row: 2;
width: 100%;
}
<h3>
Welcome to my GitHub Pages website this is where you can learn about me,
find my games, and suggest ideas for anything!
</h3>
<div id="cards" class="cards">
<div id="project1" class="project-card project-card__1">
<h1>Web Designer Tycoon</h1>
<p>
This is a idle tycoon like game where you have to make money by making
web programs. People buy your web programs for money. If you get
better at coding (in the game) then you will get more money for each
program you make. Itis currently in the BETA stage and it will get
released after lots of testing and a couple more changes. Thank you
for your patience.
<span
onclick="window.location.href = 'https://codepen.io/hacker19374/project/full/Zyraey/'"
>Click me to go to Web Designer Tycoon</span
>
</p>
</div>
<div id="project2" class="project-card project-card__2">
<h1>Burger Clicker</h1>
<p>
This game is a little bit different. It is a clicker game where you
clic and click and click over and over to try to get the most money
you can and you can use that money to buy
</p>
</div>
</div>
I'm currently working with a figure element and figure caption and I wish to make it so that when hovered over the image will have a 50% grey opacity overlay with white text, that when clicked will take you to another page via href/
How would I best go around this with my current code?
Cheers and thank you!
Here is my HTML:
<figure>
<img src="imgs/superfood-fresh-pink-raspberrys.jpg" class="superfoodcara"
alt="A pile of fresh pink raspberrys">
<figcaption class="figcap-bold"> Raspberries</figcaption>
<figcaption>Red Raspberries contain strong antioxidants such as Vitamin C, quercetin and gallic acid that fight against cancer, heart and circulatory disease and age-related decline. They are high in ellagic acid, a known chemopreventative, and have been shown to have anti-inflammatory properties.</figcaption>
</figure>
<figure>
<img src="imgs/superfood-fresh-bright-red-strawberrys.jpg" class="superfoodcara"
alt="A pill of fresh bright red strawberrys">
<figcaption class="figcap-bold"> Strawberries</figcaption>
<figcaption>Strawberries are an excellent source of vitamins C and K as well as providing a good dose of fibre, folic acid, manganese and potassium. They also contain significant amounts of phytonutrients and flavanoids which makes strawberries bright red.</figcaption>
</figure>
<figure>
<img src="imgs/superfood-freshly-picked-blueberrys.jpg" class="superfoodcara"
alt="A pile of fresh clean blueberrys">
<figcaption class="figcap-bold"> Blueberries</figcaption>
<figcaption>The fiber, potassium, folate, vitamin C, vitamin B6, and phytonutrient content in blueberries supports heart health. The absence of cholesterol from blueberries is also beneficial to the heart. Fiber content helps to reduce the total amount of cholesterol in the blood and decrease the risk of heart disease.</figcaption>
</figure>
<figure>
<img src="imgs/superfood-fresh-acai-berries.jpg" class="superfoodcara"
alt="A pill of fresh acai berries">
<figcaption class="figcap-bold"> Acai Berries</figcaption>
<figcaption>Thanks to their high antioxidant content, acai berries have many potential health benefits. They're loaded with powerful plant compounds that act as antioxidants and could have benefits for your brain, heart and overall health. They also deliver healthy fats and fiber, making them a generally healthy food.</figcaption>
</figure>
<figure>
<img src="imgs/superfood-fresh-wild-blackberrys.jpg" class="superfoodcara"
alt="A pile of fresh wild blackberrys">
<figcaption class="figcap-bold"> Blackberries</figcaption>
<figcaption>Blackberries contain a wide array of important nutrients including potassium, magnesium and calcium, as well as vitamins A, C, E and most of our B vitamins. They are also a rich source of anthocyanins, powerful antioxidants that give blackberries their deep purple colour.</figcaption>
</figure>
<figure>
<img src="imgs/superfood-fresh-organic-cranberrys.jpg" class="superfoodcara"
alt="A pile of fresh organic cranberrys">
<figcaption class="figcap-bold"> Cranberries</figcaption>
<figcaption>Many people consider cranberries to be a superfood due to their high nutrient and antioxidant content. In fact, research has linked the nutrients in cranberries to a lower risk of urinary tract infection (UTI), the prevention of certain types of cancer, improved immune function, and decreased blood pressure.</figcaption>
</figure>
/* ======================= superfood flexbox ======================= */
.flex-container {
display: flex;
flex-wrap: wrap;
margin-left: 15%;
margin-right: 5.22%;
}
/* ======================= superfood image - flexbox ======================= */
figure {
display: flex;
flex-flow: column;
width: 30%;
height: 375px;
margin-bottom: 265px;
padding-right: 30px;
margin-top: 40px;
}
.superfoodcara {
height: 375px;
}
/* ======================= superfood image caption ======================= */
figcaption {
background-color: #f2f2f2;
color: #000000;
padding: 5px 15px 10px 15px;
text-align: center;
}
To make it a link, you'll have to put an anchor tag around the figure or use scripting. You can get the visual result you want by using :after like below. It looks a little odd as I didn't want to change your CSS too much but it should give you a good enough idea.
/* ======================= superfood flexbox ======================= */
.flex-container {
display: flex;
flex-wrap: wrap;
margin-left: 15%;
margin-right: 5.22%;
}
/* ======================= superfood image - flexbox ======================= */
figure {
display: flex;
flex-flow: column;
width: 30%;
height: 375px;
margin-bottom: 265px;
padding-right: 30px;
margin-top: 40px;
}
.superfoodcara {
height: 375px;
}
/* ======================= superfood image caption ======================= */
figcaption {
background-color: #f2f2f2;
color: #000000;
padding: 5px 15px 10px 15px;
text-align: center;
}
figure:hover:after{
content: "";
background-color: black;
opacity: .5;
position: absolute;
width: 30%;
height: 100%;
}
<a href="google.com"><figure>
<img src="imgs/superfood-fresh-pink-raspberrys.jpg" class="superfoodcara"
alt="A pile of fresh pink raspberrys">
<figcaption class="figcap-bold"> Raspberries</figcaption>
<figcaption>Red Raspberries contain strong antioxidants such as Vitamin C, quercetin and gallic acid that fight against cancer, heart and circulatory disease and age-related decline. They are high in ellagic acid, a known chemopreventative, and have been shown to have anti-inflammatory properties.</figcaption>
</figure></a>
I am developing a website and am trying to remove the "View More" button which if clicked on takes you to a bigger verion of the image. My code is below:
HTML
<figure class="effect-oscar wowload fadeInUp">
<img src="images/portfolio/Mahin.png" alt="img01"/>
<figcaption>
<p>MS Site<br>
<a href="images//portfolio/Mahin.png" class = "mahinport" title="MS" data-gallery>View more</a>
View Site</p>
</figcaption>
</figure>
CSS
#media (max-width: 357px) {
.mahinport data-gallery{
display: none;
}
}
#media (max-width: 767px) {
.mahinport data-gallery{
display: none;
}
}
I tried to display the data gallery to none but that doesn't work. Thought it would be really simple but turns out I was wrong, will really appreciate some help.
data-gallery is an attribute.
You would select your element using the attribute selector ([]) like this:
.mahinport[data-gallery] {
display: none;
}
Or simply:
[data-gallery] {
display: none;
}