CSS table cell alignment and ellipsis not working - html

I have some HTML code that is not hidden and cut off using the CSS ellipsis.
I have tried many things to fix this issue, but nothing works for me (and it is killing me I cannot fix such a simple issue). I have read all the SO posts about the CSS ellipsis.
Here is a visual representation of what I have:
As shown the 11/2001 (2 annees, 10 mois) is dropped to the next line and the ellipsis does not take effect.
I am trying to keep the 11/2001 (2 annees, 10 mois) next to the prompt Date d'achevement and to be cut off (hidden) with the ellipsis if the value is too long, as it is in this case.
Here is my HTML
<div id="live_preview" class="livePreview_resumeWrapper1">
<div class="resumeStyleWrapper25">
<div class="resumeStyleOptimisedContainer25">
<div class="resumeStyleStandardHeadings25">Emploi Détails d'histoire</div>
</div>
<div class="resumeStyleWrapper25">
<div class="resumeStyleStandardTableRow25">
<div class="resumeStyleStandardContainer25">
<div class="resumeStyleStandardTableRow25">
<div class="resumeStyleStandardLabels25">employeur</div>
<div class="resumeStyleStandardLabelContent25">french</div>
</div>
<div class="resumeStyleStandardTableRow25">
<div class="resumeStyleStandardLabels25">Date de demarrage</div>
<div class="resumeStyleStandardLabels25">
<div class="resumeStyleDateStartContent25">01/2009</div>
<div class="resumeStyleFinishDateLabel25">Date d'achevement</div>
<div class="resumeStyleDateFinishContent25">
<div class="ellipsis">11/2011 (2 annees, 10 mois)</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Here is my CSS
.livePreview_resumeWrapper1 {
border: 1px solid #000;
box-shadow: 10px 10px 5px 0px #888888;
direction: ltr;
padding: 20px;
width: 93%;
}
.resumeStyleWrapper25 {
border-spacing: 0px 0px;
display: table;
font-family: verdana;
font-size: 12px;
width: 100%;
}
.resumeStyleOptimisedContainer25 {
/* THIS CLASS ALTERNATES BETWEEN A ROW AND A NON-ROW DEPENDING ON THE STYLE REQUIREMENTS */
background-color: #000;
display: table-cell;
font-weight: bold;
min-width: 149px;
padding: 2px;
text-transform: uppercase;
vertical-align: top;
width: 18%;
}
.resumeStyleStandardHeadings25 {
background-color: #000;
color: #fff;
display: table-cell;
font-weight: bold;
min-width: 149px;
padding: 2px;
text-transform: uppercase;
vertical-align: top;
width: 18%;
}
.resumeStyleStandardContainer25 {
padding-left: 5px;
width: 100%;
}
.resumeStyleStandardTableRow25 {
display: table-row;
}
.resumeStyleStandardLabels25 {
direction: ltr;
display: table-cell;
font-weight: bold;
height: 100%;
min-height: 25px;
overflow: hidden;
padding: 2px;
padding-right: 10px;
text-align: right;
vertical-align: top;
white-space: nowrap;
}
.resumeStyleDateStartContent25 {
direction: ltr;
display: table-cell;
float: left;
padding: 2px;
text-align: left;
vertical-align: top;
width: 20%;
}
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.resumeStyleFinishDateLabel25 {
background-color: #fff;
color: #000;
direction: ltr;
display: table-cell;
float: left;
font-weight: bold;
padding: 2px;
padding-right: 10px;
text-align: left;
vertical-align: top;
}
.resumeStyleDateFinishContent25 {
direction: ltr;
display: table-cell;
float: left;
padding: 2px;
text-align: left;
vertical-align: top;
}
Can anyone point out what I am doing incorrectly?
EDIT
I have updated the HTML & CSS as requested in the comments.

There is a problem of the CSS table structure, you have some table cells stay directly under the element that is also set to table cell, which is invalid. You can wrapped the inner table cell elements into a container and set it as display:table, which would fix the issue.
It's this part:
<div class="table">
<div class="resumeStyleStandardLabelContent25">
<div class="ellipsis">01/2009 Date d'achevement</div>
</div>
<div class="resumeStyleStandardLabelContent25">
<div class="ellipsis">11/2011 (2 annees, 10 mois)</div>
</div>
</div>
In general the correct CSS table layout is like this, but row isn't needed if there is only one row.
<div style="display:table">
<div style="display:table-row">
<div style="display:table-cell">
...
When you use CSS text-overflow:ellipsis in table, it needs to work with fixed table layout, and has width value set, either fixed or percentage are both fine.
It's like this:
.table {
display: table;
width: 100%;
table-layout: fixed;
}
Lastly:
Remove all the float properties from the table cells, they don't work together.
Here is the updated code snippet:
body {width: 500px;} /*for demo only*/
.livePreview_resumeWrapper1 {
border: 1px solid #000;
box-shadow: 10px 10px 5px 0px #888888;
direction: ltr;
padding: 20px;
width: 93%;
}
.resumeStyleWrapper25 {
border-spacing: 0px 0px;
display: table;
font-family: verdana;
font-size: 12px;
width: 100%;
}
.resumeStyleOptimisedContainer25 {
/* THIS CLASS ALTERNATES BETWEEN A ROW AND A NON-ROW DEPENDING ON THE STYLE REQUIREMENTS */
background-color: #000;
display: table-cell;
font-weight: bold;
min-width: 149px;
padding: 2px;
text-transform: uppercase;
vertical-align: top;
width: 18%;
}
.resumeStyleStandardHeadings25 {
background-color: #000;
color: #fff;
display: table-cell;
font-weight: bold;
min-width: 149px;
padding: 2px;
text-transform: uppercase;
vertical-align: top;
width: 18%;
}
.resumeStyleStandardContainer25 {
padding-left: 5px;
width: 100%;
}
.resumeStyleStandardTableRow25 {
display: table-row;
}
.resumeStyleStandardLabels25 {
direction: ltr;
display: table-cell;
font-weight: bold;
height: 100%;
min-height: 25px;
overflow: hidden;
padding: 2px;
padding-right: 10px;
text-align: right;
vertical-align: top;
white-space: nowrap;
}
.resumeStyleDateStartContent25 {
direction: ltr;
display: table-cell;
/* float: left; */
padding: 2px;
text-align: left;
vertical-align: top;
width: 20%;
}
.table {
display: table;
width: 100%;
table-layout: fixed;
}
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.resumeStyleFinishDateLabel25 {
background-color: #fff;
color: #000;
direction: ltr;
display: table-cell;
/* float: left; */
font-weight: bold;
padding: 2px;
padding-right: 10px;
text-align: left;
vertical-align: top;
}
.resumeStyleDateFinishContent25 {
direction: ltr;
display: table-cell;
/* float: left; */
padding: 2px;
text-align: left;
vertical-align: top;
}
<div id="live_preview" class="livePreview_resumeWrapper1">
<div class="resumeStyleWrapper25">
<div class="resumeStyleOptimisedContainer25">
<div class="resumeStyleStandardHeadings25">Emploi Détails d'histoire</div>
</div>
<div class="resumeStyleWrapper25">
<div class="resumeStyleStandardTableRow25">
<div class="resumeStyleStandardContainer25">
<div class="resumeStyleStandardTableRow25">
<div class="resumeStyleStandardLabels25">employeur</div>
<div class="resumeStyleStandardLabelContent25">french</div>
</div>
<div class="resumeStyleStandardTableRow25">
<div class="resumeStyleStandardLabels25">Date de demarrage</div>
<div class="resumeStyleStandardLabelContent25">
<div class="table">
<div class="resumeStyleStandardLabelContent25">
<div class="ellipsis">01/2009 Date d'achevement</div>
</div>
<div class="resumeStyleStandardLabelContent25">
<div class="ellipsis">11/2011 (2 annees, 10 mois)</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Or, view the JsFiddle demo, so you can resize the frame easily to check:
Working Demo Here

Related

Div element not displaying in line with others

Div element not displaying in line with other 2 div elements present despite having the necessary space for it.
I am attempting to display a web page with 3 separate paragraphs divided into div elements, but the one on the right is seemingly stuck to the bottom of the page unless I remove the center div.
Here is the html:
<div class="Reviews">
<img src="review.jpg" alt="Needledrop Review" class="Review"> Sample Text Sample
</div>
<div class="Sales">
<img src="redcarpet.jpg" alt="JID on the Red Carpet" class="RedCarpet"> Sample Text </div>
<div class="Impact">
<img src="dreamville.jpg" alt="JID with Dreamville members" class="Dream"> Sample
</div>
Here is the CSS for each div element:
div.Reviews {
float: left;
border: 1px solid black;
font-size: 1.207em;
width: 400px;
height: 770px;
text-align: justify;
color: white
}
img.Review {
vertical-align: text-top;
width: 100%;
}
Number 2:
div.Sales {
display: block;
margin-left: auto;
margin-right: auto;
border: 1px solid black;
font-size: 1.207em;
width: 400px;
height: 770px;
text-align: justify;
color: white
}
img.RedCarpet {
vertical-align: text-bottom;
width: 100%;
}
Number 3:
div.Impact {
float: right;
font-size: 1.207em;
border: 1px solid black;
padding: 10px;
width: 255px;
height: 737px;
text-align: justify;
color: white
}
img.Dream {
vertical-align: text-top;
width: 100%;
}
Any help would be appreciated, thank you!
.container {
display: flex;
}
div.Reviews {
float: left;
border: 1px solid black;
font-size: 1.207em;
width: 400px;
height: 770px;
text-align: justify;
color: white
}
img.Review {
vertical-align: text-top;
width: 100%;
}
div.Sales {
display: block;
margin-left: auto;
margin-right: auto;
border: 1px solid black;
font-size: 1.207em;
width: 400px;
height: 770px;
text-align: justify;
color: white
}
img.RedCarpet {
vertical-align: text-bottom;
width: 100%;
}
div.Impact {
float: right;
font-size: 1.207em;
border: 1px solid black;
padding: 10px;
width: 255px;
height: 737px;
text-align: justify;
color: white
}
img.Dream {
vertical-align: text-top;
width: 100%;
}
<div class="container">
<div class="Reviews">
<img src="https://www.typinks.com/images/character-sketch-of-friar-laurence-in-romeo-and-juliet.webp" alt="Needledrop Review" class="Review"> Sample Text Sample
</div>
<div class="Sales">
<img src="https://www.typinks.com/images/role-of-fate-in-romeo-and-juliet.webp" alt="JID on the Red Carpet" class="RedCarpet"> Sample Text </div>
<div class="Impact">
<img src="https://www.typinks.com/images/along-with-the-raptors.webp" alt="JID with Dreamville members" class="Dream"> Sample
</div>
</div>
add a parent div with display:flex to align in horizontal

How to fit in small box title and subtitle use css

I work with dynamicaly created boxes, and i have issues that text are not fiting inside box.
EX:
My code:
HTML:
<div class="box" id="box98" style="width: 110px; height: 43px;">
<div class="machine-icon" id="machine98" style="background-color: green;">
<img src="https://via.placeholder.com/150/">
</div>
<div class="title-box">SOME WERY BIG DATA 1345135131421124</div>
<div class="desc-box">SUB DATAqfqwfqwf</div>
</div>
CSS:
.box {
background-color: #ccc;
margin: 10px;
border-radius: 10px;
text-align: center;
font-size: 10px;
}
.machine-icon {
vertical-align: middle;
float: left;
width: 40px;
height: 40px;
background-color: #808080;
border-radius: 20px;
margin: 2px;
}
.machine-icon > img {
margin-top: 25%;
width: 20px;
height: 20px;
}
.title-box {
color: #000;
font-size: 10px;
overflow: hidden;
font-weight: 600;
}
.desc-box {
color: #000;
}
So my idea was to not showing all text, just end, for example:
I try to use display: flex and justify-content: end; idea was, to add for title and sub title z-index: 1 and for image z-index: 2, and for box overflow: hidden;
But it's not working for me.
This could be done this way using white-space: nowrap; and direction: rtl;
.box {
background-color: #ccc;
margin: 10px;
border-radius: 10px;
text-align: center;
font-size: 10px;
}
.machine-icon {
vertical-align: middle;
float: left;
width: 40px;
height: 40px;
background-color: #808080;
border-radius: 20px;
margin: 2px;
}
.machine-icon>img {
margin-top: 25%;
width: 20px;
height: 20px;
}
.title-box {
color: #000;
font-size: 10px;
overflow: hidden;
font-weight: 600;
direction: rtl;
white-space: nowrap;
}
.desc-box {
color: #000;
}
<div class="box" id="box98" style="width: 110px; height: 43px;">
<div class="machine-icon" id="machine98" style="background-color: green;">
<img src="https://via.placeholder.com/150/">
</div>
<div class="title-box">SOME WERY BIG DATA 1345135131421124</div>
<div class="desc-box">SUB DATAqfqwfqwf</div>
</div>
Remove Height from your in the .box element.
the height should be Auto:
<div class="box" id="box98" style="width: 110px; **height: auto;**">
<div class="machine-icon" id="machine98" style="background-color: green;">
<img src="https://via.placeholder.com/150/">
</div>
<div class="title-box">SOME WERY BIG DATA 1345135131421124</div>
<div class="desc-box">SUB DATAqfqwfqwf</div>
</div>

2 divs in 1 line

How to make this div starts after the picture.
It starts from the beginning of the container.
I have added /float: left;/ in profile image.
enter image description here
HTML and CSS Code:
.profile{
border: 1px solid #ddd;
padding: 22px;
min-height: 150px;
}
.profile img{
max-width: 150px;
width: 100%;
float: left;
}
.profile #details{
margin-left: 50px;
}
<section class="profile">
<img src="https://www.sonypark360.net/wp-content/uploads/2017/08/profile-pictures.png" alt="profile">
<div id="details">
<h1>Name</h1>
<h2>Age</h2>
<h3>City, Country</h3>
</div>
</section>
This code should work for you
.my-profiles {
border: 1px solid #b2cbe3;
padding: 22px;
font-family: arial;
display: inline-block;
}
.my-profiles img{
max-width: 100px;
width: 100%;
border-radius: 50%;
float: left;
}
.my-profiles .details {
overflow-x: hidden;
padding-top: 10px;
padding-left: 8px;
display: inline-block;
}
.my-profiles .details * {
margin: 0px;
font-size: 22px;
font-weight: 200;
}
<div class="my-profiles">
<img src="https://cdn.pixabay.com/photo/2016/08/08/09/17/avatar-1577909_960_720.png">
<div class="details">
<h2>Name</h2>
<h2>Age</h2>
<h2>City, Country</h2>
</div>
</div>

Css : divs alignment in div

My 2 secondary div don't want to be at the center of the primary.
I have this code :
HTML:
<div id="body">
<div id="content">
<div id="contact">
<div class="contact">
<img id="contact_photo" src="images/contact_photo.png">
</div>
<div class ="contact" id="contact-text">
some text<br>
some text<br>
some text
</div>
</div>
</div>
</div>
CSS :
#body{
background-image: url("../images/background_body.png");
height : 100%;
width:101%;
margin : 10px -10px;
overflow: hidden;
}
#content{
color: white;
padding: 0 0 0 395px;
height: 100%;
overflow: hidden;
font-family: "Lato";
font-size: 26px;
}
#contact{
font-size: 26px;
font-family: "Lato";
color: white;
width: 1035px;
/* background-color: green;*/
display: flex;
padding: 35px 80px 0 80px;
float:left;
text-align: center;
}
.contact{
float: none;
display: inline-block;
text-align:left;
}
#contact-text{
width: 385px;
height: 145px;
}
#contact_photo{
margin-right: 40px;
}
If someone can help me, I saw everywhere that they centered the div only with :
text-align: center;
and
float: none;
display: inline-block;
I don't find what's the matter.
Thank you
Try this:
.contact {
margin: 0 auto;
}
This makes the margins on right and left sides set to the same so that the item will be displayed in the center;

What is the blank part of my layout?

#container {
width: 250px;
margin: 0 auto;
}
.group {
border: 1px solid grey;
margin-bottom: 20px;
}
.group p {
text-align: center;
font-family: Helvetica sans-serif;
font-size: 25px;
color: #2e3d49;
}
.group img{
width: 100%;
}
<div id="container">
<div class="group">
<p>Hello World</p>
<img src="https://i.ytimg.com/vi/tntOCGkgt98/maxresdefault.jpg">
</div>
</div>
Please click the "Run code snippet" button to see the result. You can see at the bottom of the image, there is a blank part. Where does this come from?
it is the img being an inline element, so set is as display:block or because it is by default vertical-align:baseline, you can set set vertical-align:bottom
#container {
width: 250px;
margin: 0 auto;
}
.group {
border: 1px solid grey;
margin-bottom: 20px;
}
.group p {
text-align: center;
font-family: Helvetica sans-serif;
font-size: 25px;
color: #2e3d49;
}
.group img {
width: 100%;
display: block;
/* vertical-align: bottom - would work as well */
}
<div id="container">
<div class="group">
<p>Hello World</p>
<img src="https://i.ytimg.com/vi/tntOCGkgt98/maxresdefault.jpg">
</div>
</div>