There are many .story divs inside the container which is a grid item.
For each story I need text-overflow: ellipsis and for the #stories div I need only horizontal scroll bar.
I have a the following structure:
<div class="container" id="main-section">
<div id="stories">
<div class="story">
<img src="./img/stories/story1-shai.jpg" alt="story" />
<p>Full name</p>
</div>
</div>
</div>
#main-section {
margin-top: 30px;
display: grid;
grid-template-columns: 2fr 1fr;
grid-gap: 30px;
}
#main-section #stories {
height: 120px;
width: 620px;
background: white;
border: 1px #dcdcdc solid;
border-radius: 5px;
display: flex;
text-align: center;
align-items: center;
justify-content: start;
padding-left: 10px;
overflow-x: scroll;
}
#main-section #stories .story {
height: 80px;
max-width: 74px;
border-radius: 50%;
margin-right: 10px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
font-size: 0.7rem;
}
#main-section #stories img {
height: 55px;
width: 55px;
border-radius: 50%;
}
I've tried a fixed width for the #stories div but it only made the images to be distorted (due to overlapping).
The end result is that the longer names has a perfectly rounded images, the shorter ones has a distorted circular border, all of the name are cut (the beginning and the end of each name isn't visible) and all of the .story divs are compressed within the #stories div (tried overflow-x but it shows as disabled and makes no difference).
#main-section #storiesno need to. Hopefully you don't have any#else #storiesin the same page, have you? IDs are unique. use only#stories</div>in your HTML sample?#main-sectionis there because it contains more divs other than#stories, I understand the CSS will work the same without this specification. I've fixed the missing tag, thanks!