How to create MSN-like news cards? - html

The MSN has news cards recommendation on its website. The image overlay color and the bottom color of the card sink in well, the text is displayed over it. The cards has various colors and looks good. How to create similar effect with HTML and CSS? The below code is similar but it doesn't look as good as MSN.
HTML
<ul class="card-wrapper">
<li class="card">
<img src='https://images.unsplash.com/photo-1611916656173-875e4277bea6?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHw&ixlib=rb-1.2.1&q=80&w=400' alt=''>
<h3>The image above needs to have transparent overlay on the top</h3>
<p>But has to mingle smoothly with bottom white/black/#cee4e4 color card footer.</p>
</li>
<li class="card">
<img src='https://images.unsplash.com/photo-1611083360739-bdad6e0eb1fa?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHw&ixlib=rb-1.2.1&q=80&w=400' alt=''>
<h3>The text can be get into the bottom of the image</h3>
<p>where the color gets faded away to show clear image.</p>
</li>
<li class="card">
<img src='https://images.unsplash.com/photo-1613230485186-2e7e0fca1253?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHw&ixlib=rb-1.2.1&q=80&w=400' alt=''>
<h3>The card just needs to look like the MSN news cards</h3>
<p>Just like in the example image - https://i.imgur.com/sU6Kofb.png.</p>
</li>
</ul>
SCSS
.card {
--card-gradient: rgba(0, 0, 0, 0);
--card-gradient: #1c00ff00, #cee4e4;
// --card-gradient: tomato, orange;
--card-blend-mode: overlay;
// --card-blend-mode: multiply;
background-color: #fff;
border-radius: 0.5rem;
box-shadow: 0.05rem 0.1rem 0.3rem -0.03rem rgba(0, 0, 0, 0.45);
padding-bottom: 1rem;
background-image: linear-gradient(
var(--card-gradient),
white max(9.5rem, 27vh)
);
overflow: hidden;
img {
border-radius: 0.5rem 0.5rem 0 0;
width: 100%;
object-fit: cover;
// height: max(10rem, 25vh);
max-height: max(10rem, 30vh);
aspect-ratio: 4/3;
mix-blend-mode: var(--card-blend-mode);
// filter: grayscale(100);
~ * {
margin-left: 1rem;
margin-right: 1rem;
}
}
> :last-child {
margin-bottom: 0;
}
&:hover,
&:focus-within {
--card-gradient: #dbdbdb max(8.5rem, 10vh);
}
}
/* Additional demo display styles */
* {
box-sizing: border-box;
}
body {
display: grid;
place-content: center;
justify-items: center;
min-height: 100vh;
margin: 0;
padding: 1rem;
line-height: 1.5;
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir,
helvetica neue, helvetica, Ubuntu, roboto, noto, segoe ui, arial, sans-serif;
color: #444;
background-color: #e1faf1;
}
.card h3 {
margin-top: 1rem;
font-size: 1.25rem;
}
.card a {
color: inherit;
}
.card-wrapper {
list-style: none;
padding: 0;
margin: 0;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(30ch, 1fr));
grid-gap: 1.5rem;
max-width: 100vw;
width: 120ch;
padding-left: 1rem;
padding-right: 1rem;
}
View on Codepen
The above code gives similar effect but it doesn't look as good as MSN news cards. The above card doesn't display a clear transparent image and doesn't look as good as MSN news cards.
Live example at MSN

Here is a snippet, using position, you need to wrap div around h3 and p
.card-wrapper {
list-style: none;
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20px
}
.card {
position: relative
}
.card div {
/* Note: this variables are from msn dark mode - change to the values you prefer */
--gradient-mid-color: rgba(46, 46, 46, .8);
--gradient-color: #2e2e2e;
--radial-gradient-color: rgba(46, 46, 46, 0);
position: absolute;
z-index: 1;
bottom: 0;
right: 0;
left: 0;
padding: 10px;
background: linear-gradient(180deg, transparent 0%, var(--gradient-mid-color) 62.5%, var(--gradient-color) 100%);
color: #fff;
width: 100%;
box-sizing: border-box;
}
.card img {
width: 100%;
aspect-ratio: 1;
object-fit: cover;
}
.card a {
color: inherit;
text-decoration: none
}
<ul class="card-wrapper">
<li class="card">
<img src='https://images.unsplash.com/photo-1611916656173-875e4277bea6?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHw&ixlib=rb-1.2.1&q=80&w=400' alt=''>
<div>
<h3>The image above needs to have transparent overlay on the top</h3>
<p>But has to mingle smoothly with bottom white/black/#cee4e4 color card footer.</p>
</div>
</li>
<li class="card">
<img src='https://images.unsplash.com/photo-1611083360739-bdad6e0eb1fa?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHw&ixlib=rb-1.2.1&q=80&w=400' alt=''>
<div>
<h3>The text can be get into the bottom of the image</h3>
<p>where the color gets faded away to show clear image.</p>
</div>
</li>
<li class="card">
<img src='https://images.unsplash.com/photo-1613230485186-2e7e0fca1253?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MXwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHw&ixlib=rb-1.2.1&q=80&w=400' alt=''>
<div>
<h3>The card just needs to look like the MSN news cards</h3>
<p>Just like in the example image - https://i.imgur.com/sU6Kofb.png.</p>
</div>
</li>
</ul>

Related

Why page don't grow the html element page when I resize the page on mobile view?

I have a simple grid inside a page. On the desktop view, items are aligned horizontally, when it goes under 60px, items are go vertically. So far so good. The height of my page on desktop mode is full.
When I resize the page on mobile view, the HTML page's elements don't grow with the height of the content element inside it. it goes overflow.
why?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Document</title>
</head>
<body>
<main class="wrapper">
<section class="page hero">
<h1>You thirsty?</h1>
<article>
<p>
Explore local breweries with just one click and stirred by starlight
across the centuries light years great turbulent clouds
circumnavigated paroxysm of global death.
</p>
Browse Breweries
</article>
</section>
<section class="page areas network" id="network">
<ul>
<li>
<figure>
<!-- Photo by Quentin Dr on Unsplash -->
<img
src="https://images.unsplash.com/photo-1471421298428-1513ab720a8e"
alt="Several hands holding beer glasses"
/>
<figcaption><h3>Billions upon billions</h3></figcaption>
</figure>
<p>
Made in the interiors of collapsing stars star stuff harvesting
star light venture billions upon billions Drake Equation brain is
the seed of intelligence?
</p>
Visit Website
</li>
<li>
<figure>
<!-- Photo by Drew Farwell on Unsplash -->
<img
src="https://images.unsplash.com/photo-1513309914637-65c20a5962e1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=3450&q=80"
alt="Several friends doing a toast"
/>
<figcaption><h3>Drake Equation</h3></figcaption>
</figure>
<p>
Another world citizens of distant epochs from which we spring
descended from astronomers Orion's sword shores of the cosmic
ocean.
</p>
Visit Website
</li>
<li>
<figure>
<!-- Photo by Rawpixel on Unsplash -->
<img
src="https://images.unsplash.com/photo-1535359056830-d4badde79747?ixlib=rb-1.2.1&auto=format&fit=crop&w=3402&q=80"
alt="Three different glasses of beer"
/>
<figcaption><h3>Vast cosmic arena</h3></figcaption>
</figure>
<p>
Galaxies the ash of stellar alchemy prime number science
inconspicuous motes of rock and gas brain is the seed of
intelligence.
</p>
Visit Website
</li>
</ul>
</section>
</main>
<footer>
<p>© 2019. Made with ❤ and CSS Grid.</p>
</footer>
</body>
</html>
/* Typography imported from Google Fonts */
#import url("https://fonts.googleapis.com/css?family=Playfair+Display|Source+Sans+Pro:200,400");
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "Playfair Display", serif;
}
p,
a {
font-family: "Source Sans Pro", sans-serif;
}
/* Generic styles */
html {
scroll-behavior: smooth;
}
a {
background-color: goldenrod;
text-decoration: none;
color: white;
border-radius: 0.25rem;
text-align: center;
display: inline-block;
transition: all 0.3s;
}
.wraper {
display: flex;
flex-direction: column;
}
a:hover {
opacity: 0.6;
}
.page {
}
/* Styles for the hero image */
.hero {
/* Photo by mnm.all on Unsplash */
background: url("https://images.unsplash.com/photo-1518176258769-f227c798150e")
center;
background-size: cover;
padding: 4rem 2rem;
/* grid styles */
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
align-items: center;
}
.hero > * {
color: white;
}
.hero > h1 {
font-size: 4rem;
padding-bottom: 1rem;
}
.hero > article > p {
font-size: 1.5rem;
font-weight: 200;
}
.hero > article > a {
padding: 1rem;
margin-top: 0.75rem;
}
/* areas styles */
.areas {
padding: 2rem;
height: 100vh;
}
.areas > ul {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
grid-gap: 1rem;
list-style: none;
padding-inline-start: 0;
}
.areas > ul > li {
border: 1px solid #e2e2e2;
border-radius: 0.5rem;
}
.areas > ul > li > figure {
max-height: 220px;
overflow: hidden;
border-top-left-radius: 0.5rem;
border-top-right-radius: 0.5rem;
position: relative;
}
.areas > ul > li > figure > img {
width: 100%;
}
.areas > ul > li > figure > figcaption {
position: absolute;
bottom: 0;
background-color: rgba(0, 0, 0, 0.7);
width: 100%;
}
.areas > ul > li > figure > figcaption > h3 {
color: white;
padding: 0.75rem;
font-size: 1.25rem;
}
.areas > ul > li > p {
font-size: 1rem;
line-height: 1.5;
padding: 1rem 0.75rem;
color: #666666;
}
.areas > ul > li > a {
padding: 0.5rem 1rem;
margin: 0.5rem;
}
.network {
background-color: yellow;
}
.otg {
background-color: rgb(255, 62, 213);
}
/* footer */
footer {
background-color: #333;
padding: 0.75rem;
color: white;
text-align: center;
font-size: 0.75rem;
}
your issue here is that you have the section.areas height set to a static value.
.areas {
padding: 2rem;
height: 100vh;
}
If you change the height property to min-height the section will never be smaller than full screen, but the DOM will allow the section to grow past full screen.
.areas {
padding: 2rem;
min-height: 100vh;
}
It looks like there is a height set on your areas class.
If you have added it as to keep a height when there is limited data, you can change height: 100vh to min-height: 100vh in your areas class.
Here is a working codepen.

Fix CSS width issue on mobile

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
#import "variables";
#import "utilities";
body {
color: $neutral;
font-family: "Open Sans", sans-serif;
background-color: $main-bg;
}
a {
color: $cyan;
text-decoration: none;
}
ul {
list-style: none;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "Raleway", sans-serif;
}
p {
font-family: "Raleway", sans-serif;
}
#header {
grid-area: heading;
height: 100vh;
background-color: $intro-email;
position: relative;
background-image: $bg-image;
background-size: contain;
background-repeat: no-repeat;
background-position: left bottom;
// &::before {
// content: "";
// background-image: $bg-image;
// position: absolute;
// width: 100%;
// background-size: contain;
// background-repeat: no-repeat;
// background-position: left bottom;
// }
.navbar {
grid-area: heading;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6rem;
.nav-list {
display: flex;
li {
padding: 1rem 1.2rem;
text-transform: uppercase;
a {
text-decoration: none;
color: #fff;
text-transform: uppercase;
border-bottom: 3px transparent solid;
padding-bottom: 0.5rem;
transition: border-color 0.5s;
font-size: 0.8rem;
font-weight: 400;
font-family: "Raleway", sans-serif;
&:hover {
border-color: #fff;
}
&.current {
border-color: #fff;
}
}
}
}
}
.header-content {
max-width: 100%;
margin: 20px auto;
text-align: center;
width: 600px;
img {
max-width: 90%;
margin-top: -50px;
}
}
}
Variabes for CSS $intro-email: hsl(217, 28%, 15%);
$main-bg: hsl(218, 28%, 13%);
$footer-bg: hsl(216, 53%, 9%);
$testimonial-bg: hsl(219, 30%, 18%);
$neutral: hsl(0, 0%, 100%);
$cyan: hsl(176, 68%, 64%);
$blue: hsl(198, 60%, 50%);
$website-width: 1440px;
$bg-image: url("../img/bg-curvy-desktop.svg");
Container .container {
width: $website-width;
max-width: 100%;
padding: 2rem;
margin: 0 auto;
overflow: hidden;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.13.1/umd/react.production.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" />
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght#400;700&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght#400;700&display=swap" rel="stylesheet" />
<header id="header">
<div class="container">
<div class="wrapper">
<nav class="navbar">
<img src="../dist/img/logo.svg" alt="" />
<ul class="nav-list">
<li>Features</li>
<li>Team</li>
<li>SignIn</li>
</ul>
</nav>
<div class="header-content">
<img src="../dist/img/illustration-intro.png" alt="" />
<h1 class="title">
All your files in one secue location, accessible anywhere
</h1>
<p class="text">
Flyo stores all your most important files in one secure location. Access them whenever you need, share and collaborate with friends, family and co-workers
</p>
<button class="btn-main">Get Started</button>
</div>
</div>
</div>[Image showing what is happening in my code][1]
</header>
Website width is set to 1440px but anytime i move to the mobile version on my screen, width of the website is never the same and some elements of the website begin to fall out of place of the website, is there a way to fix this or should i remove the container that i am nesting the elements in because that is the website width the design was made for
For your container, consider using a responsive width like width: 100vw (i.e. 100% of viewport/window width). Or, if you really want to stick with 1440px, you can use media queries.
Media queries help applying different CSS rules to different device screen sizes, as a dummy example:
#media(max-width: 599px) {
.container {
/* Your styling for mobile phones */
}
}
#media(min-width: 600px) {
/* Your styling for desktops */
}

Landing page text hiding under image on browser resize

I don't understand why the text is going under the image before flex wrap comes into play. I know it's probably something simple but I just can't figure it out.. I have put widths on both sides of the page, but they seem to be ignored when it comes to resizing, and the text goes almost completely behind the image before flex wrap drops it below (I want the image to be on top when that happens but I'll cross that bridge when I come to it, assuming I'll use a reverse property in flex). Anyway, not sure what is going on, and apologies for the probable mess of HTML and CSS.
Thanks
<div class="layout">
<div class="left-sect">
<img class="logo" src="./images/logo.svg" alt="site logo" />
<div class="l-content">
<h1 class="s-head">We're</h1>
<h1>
Coming <br />
Soon
</h1>
<p>
Hello fellow shoppers! We're currently building our new fashion
store. Add your email below to stay up-to-date with announcements
and our launch deals.
</p>
<input type="email" class="main-form" />
<button type="submit">
<img src="./images/icon-arrow.svg" alt="form button arrow" />
</button>
</div>
</div>
<div class="right-sect">
<img class="main-img" src="./images/hero-desktop.jpg" alt="" />
</div>
</div>
</body>
CSS
:root {
--ds-red: hsl(0, 36%, 70%);
--soft-red: hsl(0, 93%, 68%);
--dg-red: hsl(0, 6%, 24%);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-size: 16px;
font-family: "Josefin Sans", sans-serif;
background-image: url(./images/bg-pattern-desktop.svg);
background-size: cover;
background-position: center;
}
.layout {
display: flex;
flex-direction: row;
/* flex-wrap: wrap; */
}
.left-sect {
padding: 4rem 10rem;
background-image: url(./images/bg-pattern-desktop.svg);
background-size: cover;
background-position: center;
width: 60%;
}
.l-content {
margin-top: 7rem;
}
.main-img {
}
.s-head {
color: var(--ds-red);
font-weight: 300;
text-transform: uppercase;
font-size: 4rem;
letter-spacing: 1.2rem;
}
h1 {
font-size: 4rem;
letter-spacing: 1.2rem;
text-transform: uppercase;
color: var(--dg-red);
font-weight: 400;
}
p {
color: var(--ds-red);
text-emphasis: left;
width: 30rem;
line-height: 1.3rem;
margin-top: 1.5rem;
}
You sould add media queries.
:root {
--ds-red: hsl(0, 36%, 70%);
--soft-red: hsl(0, 93%, 68%);
--dg-red: hsl(0, 6%, 24%);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-size: 16px;
font-family: "Josefin Sans", sans-serif;
background-size: cover;
background-position: center;
}
.layout {
display: flex;
}
.left-sect {
padding: 4rem 10rem;
background-image: url(./images/bg-pattern-desktop.svg);
background-size: cover;
background-position: center;
width: 60%;
}
.l-content {
margin-top: 7rem;
}
.main-img {
}
.s-head {
color: var(--ds-red);
font-weight: 300;
text-transform: uppercase;
font-size: 4rem;
letter-spacing: 1.2rem;
}
h1 {
font-size: 4rem;
letter-spacing: 1.2rem;
text-transform: uppercase;
color: var(--dg-red);
font-weight: 400;
}
p {
color: var(--ds-red);
text-emphasis: left;
width: 30rem;
line-height: 1.3rem;
margin-top: 1.5rem;
}
#media screen and (max-width:1070px){/* <== You sould change this to what you want.*/
html .layout{
flex-direction:column;
}
#media screen and(min-width:1017px){ /* <== You sould change this to what you want.*/
html .layout{
flex-direction:row;
}
}
<div class="layout">
<div class="left-sect">
<img class="logo" src="https://image.shutterstock.com/image-vector/dots-letter-c-logo-design-260nw-551769190.jpg" alt="site logo" />
<div class="l-content">
<h1 class="s-head">We're</h1>
<h1>
Coming <br />
Soon
</h1>
<p>
Hello fellow shoppers! We're currently building our new fashion
store. Add your email below to stay up-to-date with announcements
and our launch deals.
</p>
<input type="email" class="main-form" />
<button type="submit">
<img src="./images/icon-arrow.svg" alt="form button arrow" />
</button>
</div>
</div>
<div class="right-sect">
<img class="main-img" src="https://image.shutterstock.com/image-vector/dots-letter-c-logo-design-260nw-551769190.jpg" alt="" />
</div>

How to make a border left with custom bullet for my list, in a gradient style?

This is what I want to achieve:
Items with white background are my list items. On the left side I want to have a border, with custom bullets (custom, since we cannot change the default list bullet color -black- AFAIK). The upper part of the border should have a gradient color, from transparent to grey color for instance. As you also see in the pic, the length of the border should be longer than the actual list height (until the plus button, not till the last item ends.)
I have actually achieved some parts but i would like to know a better, cleaner way of doing it.
This is what I have so far: https://jsfiddle.net/6esLm8q1/
.list {
list-style: none;
border-width: 2px;
border-style: solid;
border-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(179,179,179)) 0 0 0 1;
}
.item {
margin-bottom: 1em;
margin-left: -1.7em;
}
.item::before {
content: "\2022";
color: grey;
font-weight: bold;
display: inline-block;
width: 1em;
margin-left: -1em;
}
<ul class="list">
<li class="item">
Test1
</li>
<li class="item">
Test2</li>
</ul>
<button>Plus
</button>
Problems are still: Aligning of bullets to item text, even if I align the bullets on the border, when I resize the window, the bullets slides to left or right slightly.
The gradient line is far more transparent at the beginning, not actually like in the "Target" pic. And the border ends where the list items end, so it does not reach until the button.
I appreciate any help till I get something close to my target pic!
You got yourself 99% there. For the linear-gradient, if you define the end-point to be lower than 100%, then you get it to fade earlier. Otherwise, it calculates the end point to be 100% and thus half of your border looks faded.
For the before psuedo-element, since in your markup you put a p tag within each li, you should put the pseudo-element on the p tag itself.
See the snippet below.
.list {
list-style: none;
border-width: 2px;
border-style: solid;
border-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(179,179,179) 40%) 0 0 0 1; /* add % to have gradient end earlier than end */
}
/* add before pseudo-element on p tag (since you include it in your markup */
.item>p:before {
content: "\2022";
color: grey;
font-weight: bold;
margin-left: -2.7em;
}
<ul class="list">
<li class="item">
<p>
Test1
</p>
</li>
<li class="item">
<p>
Test2
</p>
</li>
</ul>
<button>Plus</button>
I think your solution is already pretty good. I would create the circles with border-radius, as you have more control over the sizing and position.
Here is an example:
.list {
list-style: none;
border-width: 2px;
border-style: solid;
border-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(179, 179, 179)) 0 0 0 1;
margin: 0 0 0 1em;
}
.item {
position: relative;
}
.item:before {
position: absolute;
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
background-color: grey;
left: -2.75em;
top: .4em;
}
button {
display: inline-block;
width: 2em;
height: 2em;
margin: -.2em 0 0 .25em;
border-radius: 50%;
background: #c00;
color: white;
border: none;
}
<ul class="list">
<li class="item">
<p>Test1<br>test with line break</p>
</li>
<li class="item">
<p>Test2<br>test with<br>two line breaks</p>
</li>
</ul>
<button>+</button>
<ul class="list">
<li class="item">
<p>Test1</p>
</li>
<li class="item">
<p>Test2</p>
</li>
</ul>
<button>+</button>
Is it critical to be plain css? From my point of view you're trying to solve the issue with the wrong instruments.
What if you split the element, making the line on the left and the bullet with separate elements, positioned absolutely in the padding region of the container, and the content in subcontinent?
Something like this:
body {
background-color: #ededed;
}
.tail {
border-left-style: solid;
border-left-width: 2px;
border-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(179,179,179)) 0 0 0 1;
height: 20px;
margin-left: 20px;
}
.list {
font-size: 20px;
color: rgba(179,179,179);
list-style: disc;
border-left: 2px solid rgba(179,179,179);
margin: 0 0 0 20px;
box-sizing: border-box;
padding-bottom: 20px;
padding-left: 15px;
}
.item {
margin-bottom: 5px;
}
.item > div {
color: #555;
background-color: white;
padding: 5px;
font-size: 14px;
font-family: sans;
border-radius: 5px;
}
button {
border-radius: 50%;
background-color: #b30920;
border: none;
color: white;
box-sizing: border-box;
padding: 0;
width: 40px;
height: 40px;
overflow: hidden;
vertical-align: top;
font-size: 33px;
margin: 0;
}
<div class="tail"></div>
<ul class="list">
<li class="item"><div>Test1</div></li>
<li class="item"><div>Test2<br>test</div></li>
</ul>
<button>+</button>

Two text blocks over an image

I'm trying to put two text blocks over an image, one in the top left and the another in the bottom right. The text in the top left it's ok, but I can't put the text in the bottom right.
Here is the html code:
<section class="feed">
<div class="section">
<img src="">
<p class="text1"><span>Text 1</span></p>
<p class="text2"><span>Text 2</span></p>
</div>
<div class="section">
<img src="">
<p class="text1"><span>Text 3</span></p>
<p class="text2"><span>Text 4</span></p>
</div>
</section>
And now the CSS:
.section {
position: relative;
width: 65%;
margin: 3.375em 0 0 5%;
}
img {
width: 100%;
}
.text1 {
position: absolute;
top: 7.5%;
width: 100%;
}
.text1 span {
color: white;
font: 1.5em Helvetica, Sans-Serif;
font-weight: 300;
background: rgb(0, 0, 0);
/* fallback color */
background: rgba(0, 0, 0, 0.7);
padding: 0.625em;
}
.text2 {
/* don't know how to put this one in the bottom right */
}
.text2 span {
color: white;
font: 1em Helvetica, Sans-Serif;
font-weight: 300;
background: rgb(241, 91, 87);
/* fallback color */
background: rgba(241, 91, 87, 0.7);
padding: 0.625em;
}
Thanks.
You could just position it absolute, but starting from the bottom right, in stead of the top left you did with the first text block. Something like this:
.text2 {
position: absolute;
bottom: 0;
right: 0;
}
To see the code in action: http://jsfiddle.net/KzFDx/
here is one ez way to do this.
<div style="background= your image here no repeat, width height.....">
<p style="position, size,.... ></P>
<p style="position, size...."></P>
</div>