Minimizing data for mobile view only - css

I have a website that shows "cards" on a pinboard, 7 wide on a pc down to 4 wide on an ipad.
What I would like to happen is when the user views this on an iphone, the image with a class of "image eventItem" stays in the same location and the h4 "pinboard-day", the h4 "pinboard-date" and the p "pinboard-text" moves up on top of the image to the right and changes from black to white.
What I am trying to acheive is similar to an accordian, so that when the user clicks on the image on an iphone the standard view will appear as for pc etc.
I currently have over 150 events currently, so I am looking for a way to acheive this without having to re-write everything out again.
Any help would be appreciated.
Regards
Milton.
<div class="wrapper-pinboard">
<nav>
<div class="items">
<span id="all-btn" class="item active" data-name="all" >All</span>
<span class="item" data-name="site1" class="list">Site 1</span>
<span class="item" data-name="site2" class="list">Site 2</span>
<span class="item" data-name="site3" class="list">Site 3</span>
<span class="item" data-name="site4" class="list">Site 4</span>
<span class="item" data-name="site5" class="list">Site 5</span>
<span class="item" data-name="site6" class="list">Site 6</span>
</div>
</nav>
<div class="gallery">
<div class="image eventItem" date="30-10-21" id="site1" data-name="site1">
<span><img src="img/Site1-logo.jpg" alt=""></span>
<h4 id="pinboard-day">Thursday night</h4>
<h4 id="pinboard-date" >30th October</h4>
<p id="pinboard-text"><b>All Welcome</b> </p>
<br>
<p> $20 Entrance Fee
<br> Doors Open 6:00PM
<br> Headline act is -
<br> Intermission 7:30PM
<br>
<br> <b>Doors Close - 8:30PM</b>
</p>
<div class="card-bottom">
<img id="card-bottom-site1-image" src="img/site1-139x113px.jpg" alt="">
<p class="card-text-bottom">
Premises
<br>Street Address
<br>City
</p>
</div>
</div>
<div class="image eventItem" date="10-10-21" id="site2" data-name="site2">
<span><img src="img/Site2-logo.jpg" alt=""></span>
<h4 id="pinboard-day">Thursday night</h4>
<h4 id="pinboard-date" >10th October</h4>
<p id="pinboard-text"><b>All Welcome</b> </p>
<br>
<p> $30 Entrance Fee
<br> Doors Open 7:00PM
<br> Headline act is -
<br> Intermission 8:30PM
<br>
<br> <b>Doors Close - 9:30PM</b>
</p>
<div class="card-bottom">
<img id="card-bottom-site2-image" src="img/site2-139x113px.jpg" alt="">
<p class="card-text-bottom">
Premises
<br>Street Address
<br>City
</p>
</div>
</div>
</div>
</div>
CSS:
:root {
--light-blue: rgb(13, 110, 253);
--dark-blue: rgb(52, 73, 94);
--gold: rgb(255, 193, 7);
--black-mine: rgb(33, 36, 41);
--grey: rgb(108, 117, 125);
--white: #ffffff;
--black-pure: #000;
--light-red: rgb(255, 96, 85);
}
.wrapper-pinboard {
margin: 100px auto;
margin-left: 15px;
margin-right: 15px;
max-width: 100%;
}
.wrapper-pinboard .items {
display: flex;
max-width: 100%;
width: 100%;
justify-content: space-around;
}
#year-buttons .button-years {
display: flex;
max-width: 1600px;
width: 100%;
position: absolute;
justify-content: space-around;
top: 315px;
}
.items span {
padding: 7px 7px;
font-size: 18px;
font-weight: 500;
color: #34495e;
border-radius: 50px;
border: 2px solid #34495e;
transition: all 0.3s ease;
min-width: 100px;
text-align: center;
}
#all-btn {
width: 70px;
text-align: center;
}
.items span.active {
color: var(--white);
background: var(--dark-blue);
}
.items span:hover {
color: var(--white);
background: var(--dark-blue);
}
#click-photo {
color: var(--dark-blue);
font-size: 24px;
font-weight: 500;
padding-top: 20px;
text-align: center;
}
#days-clubs-btn {
width: 150px;
height: 30px;
position: absolute;
top: 160px;
left: 50px;
text-decoration: none;
color: #fff;
border: solid .5px var(--grey);
border-radius: 8px;
align-items: center;
justify-content: center;
}
#days-clubs-btn i {
text-align: center;
padding-left: 8px;
padding-top: 10px;
text-decoration: none;
align-items: center;
justify-content: center;
}
.gallery {
display: flex;
flex-wrap: wrap;
margin-top: 30px;
justify-content: space-evenly;
}
.gallery .image {
width: calc(100% / 7);
padding: 7px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: whitesmoke;
box-shadow: 6px 4px 18px;
}
.gallery #site1 {
width: calc(100% / 7);
padding: 10px 5px 10px 5px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: rgb(241, 241, 241);
box-shadow: 6px 4px 18px;
position: relative;
}
.gallery #site2 {
width: calc(100% / 7);
padding: 10px 5px 10px 5px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: rgb(241, 245, 229);
box-shadow: 6px 4px 18px;
position: relative;
}
.gallery #site3 {
width: calc(100% / 7);
padding: 10px 5px 10px 5px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: rgb(220, 220, 220);
box-shadow: 6px 4px 18px;
}
.gallery #site4 {
width: calc(100% / 7);
padding: 10px 5px 10px 5px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: rgb(241, 241, 241);
box-shadow: 6px 4px 18px;
}
.gallery #site5 {
width: calc(100% / 7);
padding: 10px 5px 10px 5px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: rgb(236, 237, 245);
box-shadow: 6px 4px 18px;
}
.gallery #site6 {
width: calc(100% / 7);
padding: 10px 5px 10px 5px;
margin: 5px;
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
background-color: rgb(236, 237, 245);
box-shadow: 6px 4px 18px;
}
.gallery .image span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image #site1 span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image #site2 span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image #site3 span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image #site4 span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image #site5 span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image #site6 span {
display: flex;
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.gallery .image img {
width: 100%;
vertical-align: middle;
border-radius: 8px;
}
.gallery .image #site1 img {
width: 100%;
vertical-align: middle;
}
.gallery .image #site2 img {
width: 100%;
vertical-align: middle;
}
.gallery .image #site3 img {
width: 100%;
vertical-align: middle;
}
.gallery .image #site4 img {
width: 100%;
vertical-align: middle;
}
.gallery .image #site5 img {
width: 100%;
vertical-align: middle;
}
.gallery .image #site6 img {
width: 100%;
vertical-align: middle;
}
.gallery .image.hide {
display: none;
}
.gallery .image.show {
animation: animate 0.4s ease;
width: calc(100% / 8);
height: calc(100% / 3);
border: solid .5px var(--grey);
border-radius: 8px;
position: relative;
}
/* THE DATE */
h4 {
padding-top: 10px;
text-align: center;
font-weight: 500;
font-size: 1rem;
}
/* THE TEXT */
p {
padding-bottom: 20px;
text-align: center;
font-weight: 200;
font-size: 1rem;
}
#pinboard-date {
color: var(--light-blue);
}
#pinboard-day {
color: var(--light-red);
}
#pinboard-text {
color: var(--black-pure);
}
.card-bottom {
display: flex;
flex-direction: row;
justify-content: space-evenly;
}
#card-bottom-site1-image {
width: 25%;
padding-top: 20px;
}
#card-bottom-site2-image {
width: 20%;
padding-top: 20px;
}
#card-bottom-site3-image {
width: 40%;
padding-top: 20px;
}
#card-bottom-site4-image {
width: 40%;
padding-top: 20px;
}
#card-bottom-site5-image {
width: 25%;
}
#card-bottom-site6-image {
width: 20%;
}
.card-text-bottom {
display: flex;
flex-direction: column;
font-size: 12px;
}
#card-bottom-apl2-image {
width: 33%;
height: 33%;
}

Related

my pictures are never the same (shrinking and stretching) in CSS

I'm coding 3 boxes. There is pic and title at first column, then there is paragraph and at the bottom there is a link. So the boxes are not editable, just the content is. They should look the same no matter how long the title is. But the length of title changes size of pictures.
When the title needed more than one line, the pic shrank. So I added to my code a min-width. Now the ones previosly problematic are OK, but the third are wider than before, than the two other. Now the css code for pic looks like this. It is an icon with border (as you can see):
background-size: 40px 40px;
border: 2px solid $primary-green;
border-radius: 10px;
height: 56px;
margin-bottom: 10px;
min-width: 56px;
What should I add/change to make all 3 pics looks the same?
Structure:
<div class="box box--product">
<div class="box__content">
<div class="box__title d-flex">
<div class="box__icon" style="background-image: url(\''.($atts['icon'] ? wp_get_attachment_image_src($atts['icon'], 'full')[0] : '').'\');"></div>
<div class="box__icon box__icon--hover" style="background-image: url(\''.($atts['icon_hover'] ? wp_get_attachment_image_src($atts['icon_hover'], 'full')[0] : '').'\');"></div>
<h3 class="box__hdl">'.$atts['nadpis'].'</h3>
</div>
<div class="box__excerpt match-height">
<p>'.$content.'</p>
</div>
<div class="box__more">
<hr>
Viac informácií
</div>
</div>
</div>
Sass:
.box {
$this: &;
background: $gray-lighter;
border-bottom: 7px solid $primary-green;
color: $black;
cursor: pointer;
//margin-bottom: $grid-gutter-width;
&--not-hover {
cursor: default;
}
&__title {
align-items: center;
&--subprod {
margin-bottom: 16px;
//min-height: 75px;
}
}
&__more {
text-align: center;
}
&__icon {
background: {
position: center;
repeat: no-repeat;
size: auto 44px;
}
border: 1px solid $gray-dark;
border-radius: 5px;
height: 80px;
margin-bottom: 16px;
margin-right: 10px;
width: 80px;
&--big {
background-size: 65px auto;
border-width: 2px;
height: 112px;
margin-bottom: 40px;
margin-top: 20px;
width: 112px;
}
&--hover {
border-color: $white;
display: none;
}
}
&__excerpt {
font-size: 14px;
letter-spacing: .44px;
line-height: 21px;
margin-top: 10px;
}
&--product {
border-bottom-width: 7px;
#{$this}__hdl {
color: $primary-green;
font-size: 16px;
line-height: 20px;
margin-left: 10px;
text-transform: uppercase;
}
#{$this}__content {
padding: 15px 22px 5px;
}
#{$this}__icon {
background-size: 40px 40px;
border: 2px solid $primary-green;
border-radius: 10px;
height: 56px;
margin-bottom: 10px;
min-width: 56px;
&--hover {
border-color: $white;
}
}
#{$this}__excerpt {
// border-bottom: 1px solid $primary-green;
color: $gray-dark;
margin-bottom: 15px;
}
#{$this}__more {
.link-warning,
.link-more {
letter-spacing: .4px;
margin-bottom: 10px;
}
}
&:hover,
&:focus {
#{$this}__hdl {
color: $white;
}
#{$this}__excerpt {
border-bottom-color: $white;
}
#{$this}__more {
.link-warning {
&::before {
background-image: url('../images/icon-warning--white.svg');
}
}
}
}
}
Something like this ?
.card {
width: 200px;
height: 300px;
display: inline-block;
margin: 12px;
border: 1px solid black;
overflow: hidden;
display: flex;
flex-flow: column;
}
.card .title {
flex: 0 0 32px;
width: 100%;
line-height: 32px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.card .link {
color: blue;
text-decoration: underline;
flex: 0 0 32px;
width: 100%;
line-height: 32px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.card .image {
flex: 1 1 auto;
overflow: hidden;
}
.card .image img {
height: 100%;
width: 100%;
object-fit: cover;
}
<div class="card">
<div class="title">Some title</div>
<div class="image">
<img src="https://picsum.photos/200/300">
</div>
<div class="link">Some link</div>
</div>
<div class="card">
<div class="title">Some title that is way too long to fit in 200px</div>
<div class="image">
<img src="https://picsum.photos/1024/768">
</div>
<div class="link">Some link that is also way too long for this little box</div>
</div>
Well, it is not probably best practise. But I just add
max-width: 57px; (+1px)
and it works just fine.

React fixed navbar with flexbox

so I'm trying to create my blog using the react framework, but I'm facing an issue here.
I really have been trying to tweaks settings on the css, html or even try to switch to grid instead of flexbox but I can't figure out how to make the "fixed" navbar detected by the flexbox.
Currently, the navbar works fine I guess, but the content that is supposed to be on the right, is not taking the place it should, it's taking the entire screen instead of the rigth section next to the navbar.
Some help would be highly appreciated !
body {
overflow: hidden;
height: 100vh;
top: 0;
left: 0;
margin: 0;
}
/*left box -Navbar*/
.nav-tab-text{
font-size: 1.6em;
display: block;
padding: 00px 0px 50px 0px;
text-align: center;
list-style-type: none;
display: flex;
}
.nav-tab a {
display: block;
text-align: center;
padding: 15px 18px;
text-decoration: none;
font-size: 18px;
color: aliceblue;
}
.nav-tab {
background-color: blue;
height: 100vh;
width: 18%;
border: 3px solid red;
position: fixed;
}
/*Right box - Home content*/
.home-content-container {
width: 100%;
height: 100vh;
border: 5px solid green;
}
.home-content-title {
text-align: center;
font-size: 1.7em;
text-decoration: underline;
text-decoration-thickness: 3px;
}
.home-content-featured{
border: 3px solid purple;
width: 50%;
height: 50%;
align-self: center;
margin-top: 3%;
}
.test{
display: flex;
}
function Navbar() {
return (
<div className="flex-container">
{/*left box - Navbar*/}
<nav className="nav-tab">
Home
Articles
Archives
About
</nav>
{/*Right box - Home content*/}
<div className="home-content-container">
<div className="home-content-title">
<h3>Name</h3>
</div>
<div className="home-content-featured">
<p>1</p>
</div>
</div>
<div className="test">
<p>2</p>
</div>
</div>
);
}
export default Navbar;
import Navbar from "./components/Navbar";
function App() {
return (
<div>
<Navbar />
</div>
);
}
export default App;
body {
overflow: hidden;
top: 0;
left: 0;
margin: 0;
}
/*left box -Navbar*/
.flex-container{
display: flex;
flex-flow: row;
}
.nav-tab a {
display: block;
text-align: center;
padding: 15px 18px;
text-decoration: none;
font-size: 18px;
color: aliceblue;
}
.nav-tab {
background-color: blue;
height: 100vh;
width: 18%;
border: 3px solid red;
}
/*Right box - Home content*/
.home-content-container {
width: 100%;
height: 100vh;
border: 5px solid green;
display: flex;
flex-direction: column-reverse;
}
.home-content-title {
text-align: center;
font-size: 1.7em;
text-decoration: underline;
text-decoration-thickness: 3px;
}
.home-content-featured{
border: 3px solid purple;
width: 50%;
height: 50%;
margin-top: 3%;
align-self: center;
}

Force 100% height and vertically align content in FlexBox Columns

I've looked at many other questions and answers, but can't figure out why I can't force 100% height on some flexbox columns - i.e., "Genre" with one line of text to match the height of "Song & The Artist" with two lines - while also vertically aligning and centering all text:
Codepen: https://codepen.io/bluedogranch/pen/ZEYXGmx
HTML:
<div class="Rtable Rtable--4cols Rtable--collapse">
<div class="Rtable-cell genre-cell">Genre</div>
<div class="Rtable-cell song-cell">Song<br /><span class="artist">The Artist</span></div>
<div class="Rtable-cell flag-cell">Length</div>
<div class="Rtable-cell link-cell">Link</div>
<div class="Rtable-cell genre-cell">Genre</div>
<div class="Rtable-cell song-cell">Song<br /><span class="artist">The Artist</span></div>
<div class="Rtable-cell flag-cell">Length</div>
<div class="Rtable-cell link-cell">Link</div>
</div>
CSS:
html, body {
min-height: 100%;
margin: 0 auto;
}
.Rtable {
display: flex;
height: 100%;
flex-wrap: wrap;
justify-content: center;
align-items: center;
margin: 0;
padding: 0;
}
.Rtable-cell, .genre-cell, .song-cell, .flag-cell, .link-cell {
box-sizing: border-box;
flex-grow: 0;
width: 100%;
height: 100%;
padding: 0.5em 0em 0.5em 0em;
overflow: hidden;
list-style: none;
color: #000;
font-size: 12px;
text-align: center;
}
.genre-cell {
width: 20% !important;
font-weight: bold;
}
.song-cell {
width: 40% !important;
}
.flag-cell {
width: 30% !important;
}
.link-cell {
width: 10% !important;
}
.Rtable--4cols > .Rtable-cell {
width: 25%;
}
.Rtable {
position: relative;
top: 1px;
left: 1px;
}
.Rtable-cell {
margin: -1px 0 0 -1px;
border: solid 1px #000000;
}
html, body {
min-height: 100%;
margin: 0 auto;
}
.Rtable {
display: flex;
height: 100%;
flex-wrap: wrap;
justify-content: center;
align-items: stretch;
margin: 0;
padding: 0;
}
.Rtable-cell, .genre-cell, .song-cell, .flag-cell, .link-cell {
display: flex;
box-sizing: border-box;
justify-content: center;
align-items: center;
width: 100%;
padding: 0.5em 0em 0.5em 0em;
overflow: hidden;
list-style: none;
color: #000;
font-size: 12px;
text-align: center;
}
.genre-cell {
width: 20% !important;
font-weight: bold;
}
.song-cell {
width: 40% !important;
}
.flag-cell {
width: 30% !important;
}
.link-cell {
width: 10% !important;
}
.Rtable--4cols > .Rtable-cell {
width: 25%;
}
.Rtable {
position: relative;
top: 1px;
left: 1px;
}
.Rtable-cell {
margin: -1px 0 0 -1px;
border: solid 1px #000000;
}
<div class="Rtable Rtable--4cols Rtable--collapse">
<div class="Rtable-cell genre-cell">Genre</div>
<div class="Rtable-cell song-cell"><div>Song<br /><span class="artist">The Artist</span></div></div>
<div class="Rtable-cell flag-cell">Length</div>
<div class="Rtable-cell link-cell">Link</div>
<div class="Rtable-cell genre-cell">Genre</div>
<div class="Rtable-cell song-cell"><div>Song<br /><span class="artist">The Artist</span></div></div>
<div class="Rtable-cell flag-cell">Length</div>
<div class="Rtable-cell link-cell">Link</div>
</div>

CSS - Inverted border radius to draw a rounded corner

I would like to know if there is a way to do these borders only using CSS in a way that they follow this shape:
I am trying to use CSS pseudo-elements ::after and ::before but I can't feel a kind of gap between divs. Any suggestion?
You can use pseudoelements to created rounded fragments and "clipped" borders.
.flex {
display: flex;
flex-direction: column;
align-items: flex-end;
}
.flex > * {
height: 50px;
position: relative;
display: flex;
align-items: center;
}
.flex > *:before {
content: "";
position: absolute;
display: inline-block;
top: 10px;
bottom: 0px;
left: -90px;
width: 90px;
border-right: 2px solid red;
border-bottom: 2px solid red;
border-bottom-right-radius: 10px;
}
.flex > *:after {
content: "";
position: absolute;
display: inline-block;
top: -2px;
height: 10px;
left: 0px;
width: 10px;
border-left: 2px solid red;
border-top: 2px solid red;
border-top-left-radius: 10px;
}
.flex > .one {
width: 100px;
}
.flex > .two {
width: 200px;
}
.flex > .three {
width: 300px;
}
.flex > .four {
width: 400px;
}
.degrees {
/* circle styles */
width: 30px;
height: 30px;
border-radius: 50%;
border: 1px solid red;
/* styles for centering */
display: flex;
align-items: center;
justify-content: center;
margin-left: 15px;
}
<div class="flex">
<div class="one">
<div class="degrees">1°</div>
</div>
<div class="two">
<div class="degrees">2°</div>
</div>
<div class="three">
<div class="degrees">3°</div>
</div>
<div class="four">
<div class="degrees">4°</div>
</div>
</div>
These are styles. Therefore in tag style="-moz-border-radius:5px;"
input[type=email] {
-moz-border-radius: 5px;
border-radius: 5px;
border: solid 1.4px black;
padding: 5px;
padding: 7px 7px 7px 7px;
max-width: 300px;
width: 80%;
}

Positioning buttons on the sides of the view CSS

I am trying to place a pair of buttons in line of the divs storing images on sides.
Currently i got this but it is not quite what i want:
* {
box-sizing: border-box;
}
body {
font-family: sans-serif;
background-color: darkgrey;
height: 100vh;
margin: 0;
/* for centering block both horizontally and vertically */
display: flex;
justify-content: center;
align-items: center;
}
.wrapper {
display: flex;
justify-content: center;
flex-wrap: wrap;
/*maximum 3 items, (320px + 2px border + 0.5rem margin-left + 0.5rem margin-right) � 3 */
max-width: calc(325.33px * 3 + 0.5rem * 6);
}
.wrapper > div {
margin: 0.5rem;
}
img {
width: 323.33px;
max-height: 100%;
}
.border {
border: 1px solid #fff;
position: relative;
}
.txt {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.5);
padding: 10px 20px;
color: white;
}
#media (max-width: 750px) {
.border {
width: calc(50% - 2rem);
}
.border > img {
width: 100%;
}
}
.left {
float: left;
text-align: center;
display: inline-block;
vertical-align: middle;
width: 3.5em;
height: 3.5em;
background: white;
border-radius: 50%;
margin-left: 1.5em;
}
.left:after {
border-radius: 4px;
content: '';
display: inline-block;
margin-top: 0.85em;
margin-left: 0.6em;
width: 1.2em;
height: 1.2em;
border-top: 0.6em solid #333;
border-right: 0.6em solid #333;
-moz-transform: rotate(-135deg);
-webkit-transform: rotate(-135deg);
transform: rotate(-135deg);
}
.right {
float: right;
text-align: center;
display: inline-block;
vertical-align: middle;
width: 3.5em;
height: 3.5em;
background: white;
border-radius: 50%;
margin-right: 1.5em;
}
.right:after {
border-radius: 4px;
content: '';
display: inline-block;
margin-top: 0.85em;
margin-left: -0.6em;
width: 1.2em;
height: 1.2em;
border-top: 0.6em solid #333;
border-right: 0.6em solid #333;
-moz-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
<div>
<span class='left' ></span>
<span class= 'right'></span>
<div class="wrapper">
<div class="border">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c119.0.842.842/18299802_1402951239794126_7834789447697694720_n.jpg">
<div class="txt">div text 1</div>
</div>
<div class="border">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c135.0.810.810/17332427_1876651042606993_1501112703702269952_n.jpg">
<div class="txt">div text 2</div>
</div>
<div class="border">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c84.0.912.912/16583397_677753229099565_4518661686835544064_n.jpg">
<div class="txt">Omelette du fromage</div>
</div>
<div class="border">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c135.0.810.810/16230268_1353432401412243_430046279255457792_n.jpg">
<div class="txt">How you doin?</div>
</div>
<div class="border">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c0.45.1080.1080/14547823_248508785596143_6915357097039233024_n.jpg">
<div class="txt">div text 5</div>
</div>
<div class="border">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c135.0.810.810/15801844_242832729497192_6894626767370190848_n.jpg">
<div class="txt">div text 6</div>
</div>
</div>
</div>
Click "Full page" to get a better view of the snippet.
I tried to use
float with margins but it doesn't work very well:
This is what i am trying to achieve:
Is it possible to change position of those buttons without changing what is inside div with class called wrapper? It would break positioning of those divs. If it was possible to resize buttons with divs in line that would be great!
removed display flex from body
2.
.right {
/* float: right; */ instead of using thing use left: 0;
text-align: center;
display: inline-block;
/* vertical-align: middle; */ not needed
width: 3.5em;
height: 3.5em;
background: white;
border-radius: 50%;
right: 0;
/* margin-top: 50%; */ instead of this, use top: 50% or top: 100%
position: absolute; needs to be absolute pos
top: 100%;
transform: translateY(-50%); this centers the buttons vertically
}
3.
.wrapper {
display: flex;
justify-content: center;
flex-wrap: wrap;
width: 100%;
padding: 0 48px;
}
Working:
* {
box-sizing: border-box;
}
body {
font-family: sans-serif;
background-color: darkgrey;
height: 100vh;
margin: 0;
}
.wrapper {
display: flex;
justify-content: center;
flex-wrap: wrap;
/*maximum 3 items, (320px + 2px border + 0.5rem margin-left + 0.5rem margin-right) � 3 */
width: 100%;
}
.wrapper {
display: flex;
justify-content: center;
flex-wrap: wrap;
width: 100%;
padding: 0 48px;
}
img {
width: 323.33px;
max-height: 100%;
}
.border {
border: 1px solid #fff;
position: relative;
}
.txt {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.5);
padding: 10px 20px;
color: white;
}
#media (max-width: 750px) {
.border {
width: calc(50% - 2rem);
}
.border > img {
width: 100%;
}
}
.left {
/* float: right; */
text-align: center;
display: inline-block;
/* vertical-align: middle; */
width: 3.5em;
height: 3.5em;
background: white;
border-radius: 50%;
left: 0;
/* margin-top: 50%; */
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.left:after {
border-radius: 4px;
content: '';
display: inline-block;
margin-top: 0.85em;
margin-left: 0.6em;
width: 1.2em;
height: 1.2em;
border-top: 0.6em solid #333;
border-right: 0.6em solid #333;
-moz-transform: rotate(-135deg);
-webkit-transform: rotate(-135deg);
transform: rotate(-135deg);
}
.right {
/* float: right; */
text-align: center;
display: inline-block;
/* vertical-align: middle; */
width: 3.5em;
height: 3.5em;
background: white;
border-radius: 50%;
right: 0;
/* margin-top: 50%; */
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.right:after {
border-radius: 4px;
content: '';
display: inline-block;
margin-top: 0.85em;
margin-left: -0.6em;
width: 1.2em;
height: 1.2em;
border-top: 0.6em solid #333;
border-right: 0.6em solid #333;
-moz-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
<div>
<span class='left' ></span>
<span class= 'right'></span>
<div class="wrapper">
<div class="border">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c119.0.842.842/18299802_1402951239794126_7834789447697694720_n.jpg">
<div class="txt">div text 1</div>
</div>
<div class="border">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c135.0.810.810/17332427_1876651042606993_1501112703702269952_n.jpg">
<div class="txt">div text 2</div>
</div>
<div class="border">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c84.0.912.912/16583397_677753229099565_4518661686835544064_n.jpg">
<div class="txt">Omelette du fromage</div>
</div>
<div class="border">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c135.0.810.810/16230268_1353432401412243_430046279255457792_n.jpg">
<div class="txt">How you doin?</div>
</div>
<div class="border">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c0.45.1080.1080/14547823_248508785596143_6915357097039233024_n.jpg">
<div class="txt">div text 5</div>
</div>
<div class="border">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c135.0.810.810/15801844_242832729497192_6894626767370190848_n.jpg">
<div class="txt">div text 6</div>
</div>
</div>
</div>

Resources