Flex div not render correctly - css

I've rows with two flex divs inside each one. In one div i show an image and inside the other there is text. I don't understand why some divs shows correctly but in others the text overflows.
If i reload the page this bug disappears but if i delete cache it comes again.
Any ideas? Thanks in advance.
.box {
position: relative;
}
.image-box-right, .image-box-left {
width: 50%;
}
.image-box-left {
float: left;
}
.image-box-right {
float: right;
}
.title {
font-size: 0.95em;
}
.text-box-right, .text-box-left {
background-color: #d53e73;
width: 55%;
height: 80%;
color: white;
box-sizing: border-box;
padding: 15px;
/* flex align items */
display: flex;
align-items: center;
justify-content: center;
font-size: 1.1em;
position: absolute;
margin-top: 5%;
top: 0;
right: 0;
}
.text-box-left {
left: 0;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row box">
<div class="col-12 px-0">
<img class="image-box-right" src="img/image1.jpg">
<div class="text-box-left dark">
<p class="title"><span>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</span>
<a href="../shared/note.html"> MORE <i class="fa fa-arrow-right"
aria-hidden="true"></i></a>
</p>
</div>
</div>
</div>
<div class="row box">
<div class="col-12 px-0">
<img class="image-box-left" src="img/image2.jpg">
<div class="text-box-right">
<p class="title"><span>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</span>
<a href="../shared/note.html">MORE <i class="fa fa-arrow-right"
aria-hidden="true"></i></a>
</p>
</div>
</div>
</div>

I don't think you need inline-block:
.notes-text-box-right, .notes-text-box-left {
background-color: #d53e73;
width: 55%;
height: 80%;
color: white;
box-sizing: border-box;
padding: 15px;
/* flex align items */
display: flex;
align-items: center;
justify-content: center;
font-size: 1.1em;
position: absolute;
margin-top: 5%;
top: 0;
right: 0;
}

You wrote two displaysettings in one CSS rule:
.notes-text-box-right, .notes-text-box-left {
[...]
display: flex;
[...]
display: inline-block;
[...]
}
The second one overwrites the first one, so you better erase that.

Related

How to create a css vertical line with circles and text on side in reactjs?

Hi I have been trying to create something as showing in the image below but I do not know if my way of doing is correct or not, if not could you please correct me.
Thanks
please see the code I have tried:
<Box className="education-details">
<div className="circle"> </div>
<div className="not-circle">
<p className="education-degree">masters</p>
<p className="education-year"> 2017/2019</p>
<p className="education-location">Dublin business school</p>
</div>
<div className="circle"> </div>
<div className="not-circle">
<p className="education-degree">masters</p>
<p className="education-year"> 2017/2019</p>
<p className="education-location">Dublin business school</p>
</div>
<div className="circle"> </div>
<div className="not-circle">
<p className="education-degree">masters</p>
<p className="education-year"> 2017/2019</p>
<p className="education-location">Dublin business school</p>
</div>
</Box>
the CSS part
.education-details {
box-sizing: border-box;
}
.circle {
width: 17px;
height: 17px;
background-color: rgb(255, 0, 0);
border-radius: 50%;
margin-left: -1.75%;
position: absolute;
}
.not-circle {
/* margin-top: -30px;
margin-left: 1.5vw; */
}
The result
codesand box link
Finally, as your question was quite interesting, I played with codepen.io to create something similar to your original picture. I reduced a bit the HTML content like I mentionned in my comment as I prefer using pseudo-elements when possible for graphical concerns.
The HTML sementic could be improved by the use of <section>, <ul> and <li> elements also. In my proof of concept I just used <div> elements. I also prefered using <h2>, <h3> and <time> tags instead of ordinary <p> tags.
You can play with my codepen here: https://codepen.io/patacra/pen/wvperjL
You can see it here after SCSS was compiled to CSS:
html, body {
margin: 0;
position: relative;
}
html {
background-color: #f6f6f6;
}
html::before {
content: "";
display: block;
position: absolute;
z-index: -1;
border-radius: 50%;
background-color: #ffebeb;
top: 8em;
right: -8em;
width: 15em;
height: 15em;
}
body {
padding: 1em;
font-family: Arial, sans serif;
font-size: 14px;
}
body::before, body::after {
content: "";
display: block;
position: absolute;
z-index: -1;
border-radius: 50%;
background-color: #ffebeb;
}
body::before {
top: -10em;
left: -15em;
width: 25em;
height: 30em;
}
body::after {
top: -12em;
right: -12em;
width: 25em;
height: 25em;
}
.timelines {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: flex-start;
}
.timeline-title {
font-size: 1em;
font-weight: bold;
}
.timeline-item {
margin-bottom: 2em;
}
.timeline-item h3 {
font-size: 1em;
font-weight: bold;
text-transform: uppercase;
margin: 0;
position: relative;
}
.timeline-item h3::before {
content: "";
position: absolute;
left: -2.35em;
background-color: #fe4747;
width: 0.7em;
height: 0.7em;
border-radius: 50%;
transform: translate(-0.5px, 0.2em);
}
.timeline-items {
margin: 2em;
padding: 0.01em 0 3em 2em;
border-left: 1px solid #fe4747;
}
.timeline-item {
margin-top: -0.3em;
}
.timeline-item time {
display: block;
float: left;
background-color: #ffebeb;
padding: 0.2em 0.4em;
}
.timeline-item > * {
margin: 1em 0;
}
.timeline-item .location {
clear: both;
font-size: 0.85em;
font-style: italic;
}
<div class="timelines">
<div class="timeline education">
<h2 class="timeline-title">Education</h2>
<div class="timeline-items">
<div class="timeline-item">
<h3>Master of Science in information systems with computing</h3>
<time datetime="2017/2019">2017 – 2019</time>
<div class="location">Dublin Business School, Dublin, Ireland</div>
</div>
<div class="timeline-item">
<h3>Bachelor of electrical engineering</h3>
<time datetime="2011/2016">2011 – 2016</time>
<div class="location">North Maharashtra University, Jalgaon, India</div>
</div>
<div class="timeline-item">
<h3>Boys town public school</h3>
<time datetime="2009/2010">2009 – 2010</time>
<div class="location">Dublin Business School, Dublin, Ireland</div>
</div>
</div>
</div>
<div class="timeline experience">
<h2 class="timeline-title">Experience</h2>
<div class="timeline-items">
<div class="timeline-item">
<h3>Sofware developer</h3>
<time datetime="2020/2022">2020 – Present</time>
<div class="location">Kare, Newbridge, Ireland</div>
</div>
<div class="timeline-item">
<h3>Junior developer</h3>
<time datetime="2019/2020">2017 – 2019</time>
<div class="location">Unipupil limited, Dublin, Ireland</div>
</div>
<div class="timeline-item">
<h3>Junior developer</h3>
<time datetime="2015/2017">2017 – 2019</time>
<div class="location">Dublin Business School, Dublin, Ireland</div>
</div>
</div>
</div>
</div>

h3 s with spaces between and same line

Hi i have three h3 (masthead-brand 0-2)
now i saw on the internet that display inline block makes them on the same line, but my idea was having them in the same line AND having spaces between that: masthead is on the left corner of the website, masthead1 is in the center, and masthead2 is in the right corner of the website.
How could i do it?
.masthead-brand {
text-align: left;
font-size: 50px;
margin-right: 30px;
margin-top: 10px;
margin-bottom: 10px;
color: #3434f3;
}
.masthead-brand1 {
text-align: center;
font-size: 50px;
margin-right: 30px;
margin-top: 10px;
margin-bottom: 0px;
}
.masthead-brand2 {
text-align: right;
font-size: 50px;
margin-top: 10px;
margin-bottom: 10px;
color: crimson;
}
h3 {
display: inline-block;
}
<div class="background">
<div>
<h3 class="masthead-brand">Held </h3>
<h3 class="masthead-brand1"> oder</h3>
<h3 class="masthead-brand2"> Schurke?</h3>
</div>
<nav>
<ul class="nav masthead-nav">
<li class="active"><a [routerLink]="['/dashboard']">Dashboard</a></li>
<li><a routerLink="/heroes">Heroes</a></li>
<li><a routerLink="/villains">Schurken</a></li>
</ul>
</nav>
<p class="lead">
Kämpfe jetzt!
</p>
<router-outlet></router-outlet>
</div>
Just add any class to h3' wrapper div:
<div class="wrapper">
<h3 class="masthead-brand">Held</h3>
<h3 class="masthead-brand1">oder</h3>
<h3 class="masthead-brand2">Schurke?</h3>
</div>
and make it flex:
.wrapper {
display: flex;
justify-content: space-between;
}
It's semantically wrong to use 3 seperate headlines.
You should rather use one headline and format its contents.
Here I did it with the help of span elements.
The positioning is done with the help of flex. Flex offers the property to justify its contents just as you need it:
.masthead-brand {
color: #3434f3;
}
.masthead-brand1 {
}
.masthead-brand2 {
color: crimson;
}
h3 {
display: flex;
justify-content: space-between;
}
h3 span {
display: block;
}
<h3>
<span class="masthead-brand">Held</span>
<span class="masthead-brand1">oder</span>
<span class="masthead-brand2">Schurke?</span>
</h3>

The flexbox footer div does not display

I'm trying to make a design with Flexbox.
I'm trying to make a 5 row design.
Google Chrome desktop version is fine. (79.0.3945.88 (64 bit))
Mobile:
Firefox for Android 68.3.0 also works correctly.
But:
(#Menubar, #statusbar) does not appear in Mobile Google Chrome 79.0.3945.79 for Android Iframe takes up all the space. But if I scroll down, I can see.
My Css and Html Code
HTML
<div id="page">
<div id="titlebar">
<span>Title Bar</span>
<i class="fas fa-camera fa-xs"></i>
<i class="fas fa-camera fa-sm"></i>
<i class="fas fa-camera" id='filter' #click="isGizle = !isGizle"></i>
</div>
<div id="filterbar" :class="{gizle:isGizle}">
Filtre Bar
</div>
<div id="toolbar">Tool Bar</div>
<iframe id='content' class="FrameKalem" src="https://www.tcmb.gov.tr">FrameKalem</iframe>
<div id="menubar">Menü Bar</div>
<div id="statusbar">
<span>Status Bar</span>
<i class='fa fa-list' aria-hidden='true'></i>
</div>
</div>
CSS
html,
body {
margin: 0;
padding: 0;
height: 100vh;
overflow: hidden;
}
#page {
display: flex;
flex-direction: column;
height: 100vh;
justify-content: baseline;
}
#titlebar {
background-color: #2ecc71;
height: 1rem;
display: flex;
flex-direction: row;
justify-content: space-between;
}
#filterbar {
background-color: khaki;
min-height: 3rem;
}
#toolbar {
background-color: #3498db;
height: 2rem;
}
#content {
flex-grow: 1;
border: 0px;
min-height: 1rem;
}
#menubar {
background-color: darkorange;
height: 2rem;
}
#statusbar {
background-color: hotpink;
height: 1rem;
}

Scale images inside divs with text

For a personal project with Angular, Angular Material and Flex-Layout I am trying to achieve a similar layout used by Bring! App:
Having images of different size (not all squared) I would like to center them proportionally and allow some text under them.
I have the following template and scss styles:
<div fxLayout="row" fxLayoutGap="5px" class="cards-container">
<div class="item-card">
<div class="image">
<img src="../../../../assets/icons/apple.png" alt="Mela" />
</div>
<span class="item-name">Mela</span>
<span class="description">12</span>
</div>
<div class="item-card">
<div class="image">
<img src="../../../../assets/icons/milk.png" alt="Latte" />
</div>
<span class="item-name">Latte</span>
<span class="description">1 description comes here, must be hidden if long text</span>
</div>
</div>
//---------------------------------------------------
.cards-container {
flex-wrap: wrap;
.item-card {
display: flex;
flex-direction: column;
justify-items: end;
color: white;
width: 7em;
height: 7em;
text-align: center;
background-color: darkslategray;
margin: 5px 0;
img {
width: 40%; // TODO: how to scale?
height: 40%;
}
.text-container {
display: flex;
flex-direction: column;
.item-name {
display: inline-block;
font-size: 1.1em;
}
.description {
width: 99%;
font-size: 0.8em;
text-align: center;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
display: inline-block;
}
}
}
}
However the images do not scale down to keep the proportions with the others images, especially if narrow and long.
It all seems to look fine but it looks like your HTML code is missing the .text-container div and class.
<div class="item-card">
<div class="image">
<img src="../../../../assets/icons/apple.png" alt="Mela" />
</div>
<span class="item-name">Mela</span>
<span class="description">12</span>
</div>
should be
<div class="item-card">
<div class="image">
<img src="../../../../assets/icons/apple.png" alt="Mela" />
</div>
<div class="text-container">
<span class="item-name">Mela</span>
<span class="description">12</span>
</div>
</div>
Now for the text-overflow: ellipsis; this doesn't work on multi-lines unless you implement some JavaScript or something.
If there is any change to your code, I'd make the images a background-image instead. There could be other ways without this, but it's what I use to make sure the container is responsive with the image always responsive and centred.
For Example: https://codepen.io/StudioKonKon/pen/wRjOzr (Includes SCSS)
.image {
background-position: center center;
background-size: contain;
background-repeat: no-repeat;
font-size: 0;
}
.image-mela {
background-image: url("https://via.placeholder.com/150x175");
}
.image-latte {
background-image: url("https://via.placeholder.com/200x50");
}
.image-long {
background-image: url("https://via.placeholder.com/50x100");
}
.cards-container {
width: 100%;
margin: auto;
display: flex;
flex-wrap: wrap;
}
.cards-container .item-card {
display: flex;
flex-direction: column;
justify-items: end;
color: white;
width: 7em;
height: 7em;
text-align: center;
background-color: darkslategray;
margin: 5px;
padding: 0.5em;
box-sizing: border-box;
overflow: hidden;
}
.cards-container .item-card .image {
display: block;
margin: auto;
width: 40%;
height: 40%;
}
.cards-container .item-card .text-container {
display: flex;
flex-direction: column;
}
.cards-container .item-card .text-container .item-name {
display: inline-block;
font-size: 1.1em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.cards-container .item-card .text-container .description {
font-size: 0.8em;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
}
<div fxLayout="row" fxLayoutGap="5px" class="cards-container">
<div class="item-card">
<div class="image image-mela">Mela</div>
<div class="text-container">
<span class="item-name">Mela</span>
<span class="description">12</span>
</div>
</div>
<div class="item-card">
<div class="image image-latte">Latte</div>
<div class="text-container">
<span class="item-name">Latte</span>
<span class="description">1 description comes here, must be hidden if long text</span>
</div>
</div>
<div class="item-card">
<div class="image image-long">Long Image</div>
<div class="text-container">
<span class="item-name">Long Image Text</span>
<span class="description">must be hidden if long text</span>
</div>
</div>
</div>
Have you tried:
img {
width: 40%;
height: auto;
}
It should leave the image proportions consistent.
It is simple. I think it will solve the problem. :)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>item</title>
<style type="text/css" media="screen">
.item-single{
width: 100px;
background-color: #e7e7e7;
height: 100px;
text-align: center;
}
.item-single span{
display: block;
border: 1px solid #000; /* just to show the alignment */
}
.item-single img{
width: 50%; /* you can scale it down using width */
border:1px solid #000; /* just to show the alignment */
display: block;
margin: auto;
}
</style>
</head>
<body>
<div class="item-single">
<img src="http://sugamparajuli.com.np/wp-content/uploads/2019/01/banana.png">
<span class="item-name">Mela</span>
<span class="description">12</span>
</div>
</body>
</html>
This is the result.
item-image

Image overlay doesn't fit

I've a problem with image overlay.
Code is here: https://codepen.io/r-smal/pen/BOBdmX
<section class="team">
<h2 class="team__title">team</h2>
<div class="team__wrapper container__team ">
<div>
<div class="team__card ">
<div class="team__overlay"></div>
<img class="team__img" src="https://i.imgur.com/vWIuUtd.jpg" alt="mako">
</div>
<h3 class="team__description">lorem</h3>
<p class="team__span">ipsum</p>
</div>
<div>
<div class="team__card ">
<div class="team__overlay"></div>
<img class="team__img" src="https://i.imgur.com/vWIuUtd.jpg" alt="mako">
</div>
<h3 class="team__description">lorem</h3>
<p class="team__span">ipsum</p>
</div>
<div>
<div class="team__card ">
<div class="team__overlay"></div>
<img class="team__img" src="https://i.imgur.com/vWIuUtd.jpg" alt="mako">
</div>
<h3 class="team__description">lorem</h3>
<p class="team__span">ipsum</p>
</div>
</section>
.container__team {
max-width: 1700px;
margin: 0 auto;
}
.team {
&__title {
margin: 100px;
text-align: center;
font-size: 30px;
text-transform: uppercase;
position: relative;
&::after{
content: "";
position: absolute;
width: 85px;
border-bottom: solid 3px #5dc6e8;
left: 48.5%;
top: 50px;
}
}
&__wrapper {
display: grid;
grid-template-columns: 33.33% auto auto;
text-align: center
}
&__description {
margin: 50px 0 20px;
text-align: center;
font-size: 35px;
}
&__span{
font-size: 35px;
text-align: center;
}
&__card {
position: relative;
}
&__overlay {
position: absolute;
background: rgba(0,0,0,0.6);
width: 100%;
height: 100%;
display: none;
}
&__img{
}
}
.team__card:hover .team__overlay{
display: block;
transition: 0.3s;
}
As you can see on codepen overlay on top of image is bigger than my image and I can't figure out why. I made it 'fit" but I have to use static margins so in resoult in mobile version it doesn't look right.
And one last question how do I position ::after element center under my text that will stay here even in mobile?Without using static margin like in my code.

Resources