Cannot reduce div height without having visualization issues - html

in this codepen:https://codepen.io/anon/pen/GGrVdK
I cannot reduce the height of the div having class foul-row to 4px height, given that every foul div is 4px tall.
.foul{
background: linear-gradient(to bottom right, rgb(0,0,0), rgb(92,92,92));
height: 4px;
margin-top:0;
margin-bottom: 0;
margin-right: 2px;
width: 15px;
display: inline-block;
}
If I try to set a height to foul-row class, either I have scrollbars in the containing cell div, or I can't see foul divs.
Here there is cell class
.cell{
padding: 6px 8px 0 8px;
white-space: nowrap;
font-size: 13px;
min-width: 27px;
display: block;
overflow: auto;
height: 36px; /*I would like to remove this, but if I do, I have visualization problems*/
}
and this is the structure of the "incriminated" cell
<div class="cell white">
<div>Home Team</div>
<div class="foul-row">
<div class="foul"></div><div class="foul"></div><div class="foul">/div><div class="foul"></div><div class="foul"></div>
</div>
</div>
How can I reduce foul-row height to fit foul height and reduce the total height of cell div? Thanks

Your height:4px is being overriteen by the font-size, which is by default 16px,because it needs to have space for the text to show up.
Now since div.foul doesn't have any text it will be fine to set it's font to 0.
body {
font-family: 'Fjalla One', sans-serif;
text-transform: uppercase;
letter-spacing: 0.02em;
/* background-image: url(https://dynamitick.com/wp-content/uploads/2018/01/legnano-basket-19-sempione-news.jpg); */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
height: 100%;
}
.red {
background-color: rgba(255, 0, 0, 0.7);
color: white;
}
.blue {
background-color: rgba(0, 0, 255, 0.7);
color: white
}
.black {
background-color: rgba(0, 0, 0, 0.7);
color: white;
}
.green {
background-color: rgba(0, 128, 0, 0.7);
color: white;
}
.yellow {
background-color: rgba(255, 255, 0, 0.7);
color: blue;
}
.white {
background-color: rgba(255, 255, 255, 0.7);
color: blue;
}
.grey {
background-color: rgba(128, 128, 128, 0.7);
color: white;
}
.score {
text-align: right;
}
.cell {
padding: 6px 8px 0 8px;
/* display: inline-flex; */
/* overflow: auto; */
white-space: nowrap;
font-size: 13px;
min-width: 27px;
/* min-height: 16px; */
display: block;
overflow: auto;
height: 36px;
/* text-overflow: ellipsis */
}
.shadow {
background: linear-gradient(rgba(255, 255, 255, 1), rgba(0, 0, 0, 1), rgba(255, 255, 255, 1));
}
.column {
display: inline-block;
height: 100%;
}
.separator {
display: inline-block;
width: 1px;
}
.timer {
/* width: 60px; */
text-align: center;
}
.container {
border-radius: 10px;
overflow: hidden;
display: table;
clear: both;
font-size: 0;
animation-name: rotation;
animation-duration: 1s;
border: 1px solid grey;
}
#keyframes rotation {
from {
transform: rotateX(90deg);
}
to {
transform: rotateX(0deg);
}
}
.bottom-left {
position: absolute;
bottom: 3vh;
left: 2vh;
}
.bottom-right {
position: absolute;
bottom: 3vh;
right: 2vh;
}
.top-right {
position: absolute;
top: 3vh;
right: 2vh;
}
.top-left {
position: absolute;
top: 3vh;
left: 2vh;
}
.message-title {
text-align: center;
}
.message-body {
text-align: center;
min-width: 150px;
background-color: rgba(0, 0, 0, 0.66);
color: white;
text-transform: none
}
.half-shadow-up {
background: linear-gradient(rgba(255, 255, 255, 1), rgba(128, 128, 128, 1));
}
.tv-logo img {
max-width: 150px;
max-height: 150px;
margin: auto;
}
.foul {
background: linear-gradient(to bottom right, rgb(0, 0, 0), rgb(92, 92, 92));
height: 4px;
margin-top: 0;
margin-bottom: 0;
font-size: 0;
margin-right: 2px;
width: 15px;
display: inline-block;
}
.foul-row {
height: 4px;
}
<link href="https://fonts.googleapis.com/css?family=Fjalla+One" rel="stylesheet">
<div class="container shadow top-right">
<div class="column timer">
<div class="cell red"><span>00:00</span></div>
<div class="cell red">Q4</div>
</div>
<div class="separator"></div>
<div class="column">
<div class="cell white">
<div>Home Team</div>
<div class="foul-row">
<div class="foul"></div>
<div class="foul"></div>
<div class="foul"></div>
<div class="foul"></div>
<div class="foul"></div>
</div>
</div>
<div class="cell green">
<div>Guest team</div>
<div class="foul-row">
<div class="foul"></div>
<div class="foul"></div>
<div class="foul"></div>
<div class="foul"></div>
<div class="foul"></div>
</div>
</div>
</div>
<div class="separator"></div>
<div class="column score">
<div class="cell white">
100
</div>
<div class="cell green">
65
</div>
</div>
</div>
<div class="container bottom-left">
<div class="column">
<div class="cell white half-shadow-up message-title">
10 A. Player
</div>
<div class="cell message-body">
24 pts, 8 reb
</div>
</div>
</div>

Please try adding your height:4px to foul-row after changing the overflow property on your cell element to hidden:
.cell{
padding: 6px 8px 0 8px;
white-space: nowrap;
font-size: 13px;
min-width: 27px;
display: block;
overflow: hidden; /* changed */
height: 36px;
}

Related

Why is there white space on the bottom of the web page

The white space is visible when I select a height over 20px at the last CSS Element. The
class "roadmap-box"
Near the bottom of the HTML Body Element. The top white box is the "roadmap-box" Click here to see the image
Whenever I try to adjust the height, the top white box becomes bigger, but also the white box at the bottom grows in size. I dont know how to fix that.
* {
margin: 0;
padding: 0;
font-family: sans-serif;
}
.banner {
width: 100%;
height: 100vh;
background-image: linear-gradient(rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.5)), url(Background/3.jpg);
background-size: cover;
background-position: center;
padding-bottom: 2100px;
}
.navbar {
width: 85%;
margin: auto;
padding: 35px 0;
display: flex;
align-items: center;
justify-content: space-between;
}
.profile-signature {
width: 300px;
object-position: top;
object-fit: contain;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
}
.navbar ul li {
list-style: none;
display: inline-block;
margin: 0 20px;
position: relative;
}
.navbar ul li a {
text-decoration: none;
color: #fff;
text-transform: uppercase;
}
.navbar ul li::after {
content: '';
height: 3px;
width: 0;
background: #009688;
position: absolute;
left: 0;
bottom: -10px;
transition: 0.5s;
}
.navbar ul li:hover::after {
width: 100%;
}
.profile-picture {
border-radius: 50%;
width: 150px;
height: 150px;
object-fit: cover;
cursor: pointer;
box-shadow: 16px 16px 32px rgba(255, 255, 255, 0.3), -16px -16px 32px rgba(255, 255, 255, 0.3);
transition: 0.5s;
}
.profile-picture:hover {
width: 275px;
height: 275px;
transform: translateY(-25px);
transition: 0.5s;
}
.content {
width: 100%;
position: absolute;
top: 60;
transform: translateY(25px);
text-align: center;
color: white;
}
.content h1 {
font-size: 70px;
margin-top: 60px;
}
.content p {
margin: 20px auto;
font-weight: 100;
line-height: 25px;
}
button {
width: 200px;
padding: 15px 0;
text-align: center;
margin: 20px 10px;
border-radius: 25px;
font-weight: bold;
border: 2px solid #009688;
background: transparent;
color: white;
cursor: pointer;
position: relative;
overflow: hidden;
}
span {
background: #009688;
height: 100%;
width: 0;
border-radius: 25px;
position: absolute;
left: 0;
bottom: 0;
z-index: -1;
transition: 0.5s;
}
button:hover span {
width: 100%;
}
button:hover {
border: none
}
.text-box {
height: 600px;
border: 3px;
border-style: none;
border-color: rgba(255, 255, 255, 0.3);
transform: translateY(500px);
display: flex;
justify-content: space-around;
}
.images-box1 {
background-color: rgba(68, 218, 185, 0.05);
border-radius: 77px;
width: 375px;
height: 628px;
border: 5px;
border-color: #1f534f;
border-style: solid none;
align-items: center;
cursor: pointer;
z-index: -1;
transition: 0.7s;
}
.images-box1:hover {
background: rgb(152, 152, 152);
background: linear-gradient(3deg, rgba(152, 152, 152, 0) 0%, rgba(255, 255, 255, 0.3113620448179272) 100%);
height: 300px;
margin-top: 20px;
background: #009688;
transition: 0.7s;
}
.text-image {
border-radius: 75px;
width: 375px;
height: 300px;
display: flex;
justify-content: left;
align-items: center;
flex-direction: column;
object-fit: cover;
object-position: middle;
}
.text-title-box1 {
text-align: start;
margin-top: 10px;
text-align: center;
}
p {
padding-top: 20px;
transition: 0.5s;
}
p:hover {
transition: 0.5s;
}
.bottom-parent {
position: relative;
}
.bottom {
display: block;
width: 100%;
position: absolute;
bottom: 0;
height: 45px;
background-color: rgb(21, 105, 87);
}
.text-bottom {
display: flex;
justify-content: center;
text-indent: 20px;
padding-right: 20px;
padding-top: 13px;
color: white;
}
.twitter-hover {
text-decoration: none;
color: white;
}
.twitter-hover:hover {
text-decoration: underline;
color: rgba(255, 255, 255, 0.685);
}
.linkedin-hover {
text-decoration: none;
color: white;
}
.linkedin-hover:hover {
text-decoration: underline;
color: rgba(255, 255, 255, 0.685);
}
.instagram-hover {
text-decoration: none;
color: white;
}
.instagram-hover:hover {
text-decoration: underline;
color: rgba(255, 255, 255, 0.685);
}
.impressum:hover {
cursor: pointer;
text-decoration: underline;
color: rgba(255, 255, 255, 0.685);
}
.roadmap-box {
width: 100%;
height: 50px;
background-color: white;
transform: translateY(-500px);
}
<div class="banner">
<div class="navbar">
<img class="profile-signature" src="Logo/logo-1.png" alt="Profile Logo">
<ul>
<li>HOME</li>
<li>PORTFOLIO</li>
<li>GAMES</li>
<li>SOCIALS</li>
<li>CONTACT</li>
</ul>
</div>
<div class="content">
<a href="https://google.com/" target="_blank">
<img class="profile-picture" src="Logo/logo-2.jpg" alt="Profile Picture">
</a>
<h1>WELCOME TO PARADISE!</h1>
<p>This is a practice website. There's just a bit of text here to fill the lines, blah blah blah.
<br>If you want to know more about me, just have a look around</p>
<div>
<a href="https://google.com/" target="_blank">
<button type="button" href="#middle"><span></span>PORTFOLIO</button>
</a>
<a href="https://twitter.com/" target="_blank">
<button type="button"><span></span>SOCIALS</button>
</a>
</div>
<div class="text-box">
<div class="images-box1">
<img src="designs/1.jpg" class="text-image">
<div>
<h2 class="text-title-box1">Random Design 1</h1>
<p></p>
</div>
</div>
<div class="images-box1">
<img src="designs/2.jpg" class="text-image">
<div>
<h2 class="text-title-box1">Fantasy Shower</h1>
<p>Well, nothing much to explain here. <br> <br> I need some text so have run reading <br> blah blah blah again <br> <br>:)</p>
</div>
</div>
<div class="images-box1">
<img src="designs/3.jpg" class="text-image">
<div>
<h2 class="text-title-box1">Light Bulb Girl</h1>
<p>This image was created 2020. <br> It shows a person beeing stuck inside a lightbulb. Funny right? No deeper <br> intentions, dont look for them, <br> lol</p>
</div>
</div>
<div class="images-box1">
<img src="designs/4.jpg" class="text-image">
<div>
<h2 class="text-title-box1">Random Design 4</h1>
<p>Test</p>
</div>
</div>
</div>
</div>
</div>
<div class="code-image-box">
<div class="code-image">
</div>
</div>
<div class="roadmap-box">
<div class="q1"></div>
<div class="q2"></div>
</div>
<div class="bottom-parent">
<div class="bottom">
<div class="text-bottom">
<a class="twitter-hover" href="https:/twitter.com/" target="_blank">
<div class="twitter">Twitter</div>
</a>
<a class="linkedin-hover" href="https:/linkedin.com/" target="_blank">
<div class="linkedin">LinkedIn</div>
</a>
<a class="instagram-hover" href="https:/instagram.com/" target="_blank">
<div class="instagram">Instagram</div>
</a>
<div class="impressum">Impressum</div>
</a>
</div>
</div>
</div>
The div with class .roadmap-box has been translatedY(-500px) but the browser has still made the space available for it as it's a block-level element. If you hide it then the gap disappears. What's the purpose of it? What are you trying to do with it?
See example below. There's also no need to make .bottom position:absoute as it then gives the div .bottom-parent no height. See modified markup below.
* {
margin: 0;
padding: 0;
font-family: sans-serif;
}
.banner {
width: 100%;
height: 100vh;
background-image: linear-gradient(rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.5)), url(Background/3.jpg);
background-size: cover;
background-position: center;
padding-bottom: 2100px;
}
.navbar {
width: 85%;
margin: auto;
padding: 35px 0;
display: flex;
align-items: center;
justify-content: space-between;
}
.profile-signature {
width: 300px;
object-position: top;
object-fit: contain;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
}
.navbar ul li {
list-style: none;
display: inline-block;
margin: 0 20px;
position: relative;
}
.navbar ul li a {
text-decoration: none;
color: #fff;
text-transform: uppercase;
}
.navbar ul li::after {
content: '';
height: 3px;
width: 0;
background: #009688;
position: absolute;
left: 0;
bottom: -10px;
transition: 0.5s;
}
.navbar ul li:hover::after {
width: 100%;
}
.profile-picture {
border-radius: 50%;
width: 150px;
height: 150px;
object-fit: cover;
cursor: pointer;
box-shadow: 16px 16px 32px rgba(255, 255, 255, 0.3), -16px -16px 32px rgba(255, 255, 255, 0.3);
transition: 0.5s;
}
.profile-picture:hover {
width: 275px;
height: 275px;
transform: translateY(-25px);
transition: 0.5s;
}
.content {
width: 100%;
position: absolute;
top: 60;
transform: translateY(25px);
text-align: center;
color: white;
}
.content h1 {
font-size: 70px;
margin-top: 60px;
}
.content p {
margin: 20px auto;
font-weight: 100;
line-height: 25px;
}
button {
width: 200px;
padding: 15px 0;
text-align: center;
margin: 20px 10px;
border-radius: 25px;
font-weight: bold;
border: 2px solid #009688;
background: transparent;
color: white;
cursor: pointer;
position: relative;
overflow: hidden;
}
span {
background: #009688;
height: 100%;
width: 0;
border-radius: 25px;
position: absolute;
left: 0;
bottom: 0;
z-index: -1;
transition: 0.5s;
}
button:hover span {
width: 100%;
}
button:hover {
border: none
}
.text-box {
height: 600px;
border: 3px;
border-style: none;
border-color: rgba(255, 255, 255, 0.3);
transform: translateY(500px);
display: flex;
justify-content: space-around;
}
.images-box1 {
background-color: rgba(68, 218, 185, 0.05);
border-radius: 77px;
width: 375px;
height: 628px;
border: 5px;
border-color: #1f534f;
border-style: solid none;
align-items: center;
cursor: pointer;
z-index: -1;
transition: 0.7s;
}
.images-box1:hover {
background: rgb(152, 152, 152);
background: linear-gradient(3deg, rgba(152, 152, 152, 0) 0%, rgba(255, 255, 255, 0.3113620448179272) 100%);
height: 300px;
margin-top: 20px;
background: #009688;
transition: 0.7s;
}
.text-image {
border-radius: 75px;
width: 375px;
height: 300px;
display: flex;
justify-content: left;
align-items: center;
flex-direction: column;
object-fit: cover;
object-position: middle;
}
.text-title-box1 {
text-align: start;
margin-top: 10px;
text-align: center;
}
p {
padding-top: 20px;
transition: 0.5s;
}
p:hover {
transition: 0.5s;
}
.bottom-parent {
position: relative;
}
.bottom {
display: block;
width: 100%;
/* position: absolute; */
bottom: 0;
height: 45px;
background-color: rgb(21, 105, 87);
}
.text-bottom {
display: flex;
justify-content: center;
text-indent: 20px;
padding-right: 20px;
padding-top: 13px;
color: white;
}
.twitter-hover {
text-decoration: none;
color: white;
}
.twitter-hover:hover {
text-decoration: underline;
color: rgba(255, 255, 255, 0.685);
}
.linkedin-hover {
text-decoration: none;
color: white;
}
.linkedin-hover:hover {
text-decoration: underline;
color: rgba(255, 255, 255, 0.685);
}
.instagram-hover {
text-decoration: none;
color: white;
}
.instagram-hover:hover {
text-decoration: underline;
color: rgba(255, 255, 255, 0.685);
}
.impressum:hover {
cursor: pointer;
text-decoration: underline;
color: rgba(255, 255, 255, 0.685);
}
.roadmap-box {
width: 100%;
height: 50px;
background-color: white;
display: none;
/*transform: translateY(-500px);*/
}
<div class="banner">
<div class="navbar">
<img class="profile-signature" src="Logo/logo-1.png" alt="Profile Logo">
<ul>
<li>HOME</li>
<li>PORTFOLIO</li>
<li>GAMES</li>
<li>SOCIALS</li>
<li>CONTACT</li>
</ul>
</div>
<div class="content">
<a href="https://google.com/" target="_blank">
<img class="profile-picture" src="Logo/logo-2.jpg" alt="Profile Picture">
</a>
<h1>WELCOME TO PARADISE!</h1>
<p>This is a practice website. There's just a bit of text here to fill the lines, blah blah blah.
<br>If you want to know more about me, just have a look around
</p>
<div>
<a href="https://google.com/" target="_blank">
<button type="button" href="#middle"><span></span>PORTFOLIO</button>
</a>
<a href="https://twitter.com/" target="_blank">
<button type="button"><span></span>SOCIALS</button>
</a>
</div>
<div class="text-box">
<div class="images-box1">
<img src="designs/1.jpg" class="text-image">
<div>
<h2 class="text-title-box1">Random Design 1</h1>
<p></p>
</div>
</div>
<div class="images-box1">
<img src="designs/2.jpg" class="text-image">
<div>
<h2 class="text-title-box1">Fantasy Shower</h1>
<p>Well, nothing much to explain here. <br> <br> I need some text so have run reading <br> blah blah blah again <br> <br>:)</p>
</div>
</div>
<div class="images-box1">
<img src="designs/3.jpg" class="text-image">
<div>
<h2 class="text-title-box1">Light Bulb Girl</h1>
<p>This image was created 2020. <br> It shows a person beeing stuck inside a lightbulb. Funny right? No deeper <br> intentions, dont look for them, <br> lol</p>
</div>
</div>
<div class="images-box1">
<img src="designs/4.jpg" class="text-image">
<div>
<h2 class="text-title-box1">Random Design 4</h1>
<p>Test</p>
</div>
</div>
</div>
</div>
</div>
<div class="code-image-box">
<div class="code-image">
</div>
</div>
<div class="roadmap-box">
<div class="q1"></div>
<div class="q2"></div>
</div>
<div class="bottom-parent">
<div class="bottom">
<div class="text-bottom">
<a class="twitter-hover" href="https:/twitter.com/" target="_blank">
<div class="twitter">Twitter</div>
</a>
<a class="linkedin-hover" href="https:/linkedin.com/" target="_blank">
<div class="linkedin">LinkedIn</div>
</a>
<a class="instagram-hover" href="https:/instagram.com/" target="_blank">
<div class="instagram">Instagram</div>
</a>
<div class="impressum">Impressum</div>
</a>
</div>
</div>
</div>

Div is smaller than the content of the Div

I've a DIV, with a button inside. Under this DIV, I've a hr, but the hr isn't under the button. I could make the DIV height bigger, but I don't know how high the button is (it depends on the browser). Can I style the DIV, that all things, which are in the code under the DIV, on the website also under the DIV are? I show below my HTML and the CSS code, and a screenshot from the result.
body {
min-height: 100vh;
}
/* centering the div that is supposed to take all content */
#center {
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
}
#wrapper {
background: rgba(255, 255, 255, 0.1);
border-radius: 50px;
box-shadow: -1px 0px 20px 0px rgba(0, 0, 0, 1);
height: 75vh;
padding: 50px;
width: 75vh;
}
hr {
border-style: none;
border-top: 1px solid black;
}
#output {
display: inline-block;
}
/* make button sit on the right side */
#copy {
float: right;
}
<div id="center">
<div id="wrapper">
<div id="top">
<div id="output"></div>
<div id="copy"><button>kopieren</button></div>
</div>
<hr>
</div>
</div>
Is your problem that you want the hr to be placed under the button? Then, applying a width: 100% to it could be a solution. But it depends on the final result you're looking for.
* {
font-family: sans-serif;
color: white;
}
/* Schriftart (Sansserif), Weiss */
body {
background-image: url(img.jpg);
background-position: center;
background-size: cover;
min-height: 100vh;
}
/* positioning background image */
#center {
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
}
/* centering the div that is supposed to take all content */
#wrapper {
backdrop-filter: blur(10px);
background: rgba(255, 255, 255, 0.1);
border-radius: 50px;
box-shadow: -1px 0px 20px 0px rgba(0, 0, 0, 1);
height: 75vh;
padding: 50px;
width: 75vh;
}
hr {
border-style: none;
border-top: 1px solid black;
width: 100%;
}
#output {
display: inline-block;
}
#copy {
float: right;
}
/* make button sit on the right side */
button {
background-color: rgb(132, 60, 116);
border: none;
padding: 8px;
border-radius: 10px;
}
<div id="center">
<div id="wrapper">
<div id="top">
<div id="output"></div>
<div id="copy"><button>kopieren</button></div>
</div>
<hr>
</div>
</div>
Just add
#top {
display: flex;
flex-direction: column;
}
Here is the result
* {
font-family: sans-serif;
color: white;
}
/* Schriftart (Sansserif), Weiss */
body {
background-image: url(img.jpg);
background-position: center;
background-size: cover;
min-height: 100vh;
}
/* positioning background image */
#center {
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
}
/* centering the div that is supposed to take all content */
#wrapper {
backdrop-filter: blur(10px);
background: rgba(255, 255, 255, 0.1);
border-radius: 50px;
box-shadow: -1px 0px 20px 0px rgba(0, 0, 0, 1);
height: 75vh;
padding: 50px;
width: 75vh;
}
hr {
border-style: none;
border-top: 1px solid black;
}
#output {
display: inline-block;
}
#copy {
float: right;
}
/* make button sit on the right side */
button {
background-color: rgb(132, 60, 116);
border: none;
padding: 8px;
border-radius: 10px;
}
#top {
display: flex;
flex-direction: column;
}
<div id="center">
<div id="wrapper">
<div id="top">
<div id="output"></div>
<div id="copy"><button>kopieren</button></div>
</div>
<hr>
</div>
</div>

Why can't i align the div that contains text next to the div that contains the image

i'm currently working on a webpage for my design class and i have a problem. This is the browser view:
I am kinda new with html and css but i have tried display in-line block, flex... Nothing worked, and i dont know what else i could do
So the problem is that the text "aaaaa" must be next to image. Here is my html code:
.caixa {
word-wrap: break-word;
width: 70%;
box-shadow: 2px 2px 30px rgba(0, 0, 0, 0.2);
margin: 25px;
margin-left: 0px;
border-radius: 10px;
}
.caixa-img {
display: inline-block;
margin: 15px;
width: 15%;
position: relative;
}
.caixa-img img {
margin-right: 120px;
border-radius: 10px;
width: 100%;
height: 100%;
}
.info {
width: 100%;
padding: 10px 20px;
}
.tipo {}
.descripcio {
display: block;
background-color: chartreuse;
}
.tipo a {
color: #222222;
margin: 5px 0px;
font-weight: 700;
letter-spacing: 0.5px;
padding-right: 8px;
}
.tipo span {
color: rgba(26, 26, 26, 0.5);
}
.preu {
color: #333333;
font-weight: 600;
font-size: 1.1rem;
font-family: poppins;
letter-spacing: 0.5px;
}
.overlay {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 100%;
height: 100%;
background-color: rgba(226, 197, 88, 0.6);
display: flex;
justify-content: center;
align-items: center;
}
.comprar {
width: 160px;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
background-color: #FFFFFF;
color: #252525;
font-weight: 700;
letter-spacing: 1px;
font-family: calibri;
border-radius: 20px;
box-shadow: 2px 2px 30px rgba(0, 0, 0, 0.2);
}
.comprar:hover {
color: #FFFFFF;
background-color: rgb(248, 171, 55);
transition: all ease 0.3s;
}
.overlay {
visibility: hidden;
}
.caixa-img:hover .overlay {
visibility: visible;
animation: fade 0.5s;
}
#keyframes fade {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
<div class="col-12 productes">
<div class="producte1">
<div class="caixa">
<div class="caixa-img">
<img alt="" src="imgExplora/imgCarrousel/herbicida.jpg">
<div class="overlay">
Comprar
</div>
<div class="tipo">
<a href="#">
<h3>HERBICIDA</h3>
</a>
<!--
<div class="rating">
<span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span>
</div>-->
</div>
55€
</div>
<div class="info">
<span class="descripcio">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span>
</div>
</div>
</div>
</div>
Below an example using flexbox (see .caixa).
.caixa {
width: 70%;
box-shadow: 2px 2px 30px rgba(0, 0, 0, 0.2);
margin: 25px 25px 25px 0;
/* margin-left: 0px; */
border-radius: 10px;
display: flex; /* Added */
}
.caixa-img {
margin: 15px;
width: 30%;
}
.caixa-img img {
border-radius: 10px;
width: 125px; /* For demo */
height: 125px; /* For demo */
}
.info {
width: 100%;
padding: 10px 20px;
}
.tipo {}
.descripcio {
display: block;
background-color: chartreuse;
word-break: break-all; /* Essential to break large words */
}
.tipo a {
color: #222222;
margin: 5px 0px;
font-weight: 700;
letter-spacing: 0.5px;
padding-right: 8px;
}
.tipo span {
color: rgba(26, 26, 26, 0.5);
}
.preu {
color: #333333;
font-weight: 600;
font-size: 1.1rem;
font-family: poppins;
letter-spacing: 0.5px;
}
.overlay {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 100%;
height: 100%;
background-color: rgba(226, 197, 88, 0.6);
display: flex;
justify-content: center;
align-items: center;
}
.comprar {
width: 160px;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
background-color: #FFFFFF;
color: #252525;
font-weight: 700;
letter-spacing: 1px;
font-family: calibri;
border-radius: 20px;
box-shadow: 2px 2px 30px rgba(0, 0, 0, 0.2);
}
.comprar:hover {
color: #FFFFFF;
background-color: rgb(248, 171, 55);
transition: all ease 0.3s;
}
.overlay {
visibility: hidden;
}
.caixa-img:hover .overlay {
visibility: visible;
animation: fade 0.5s;
}
#keyframes fade {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
<div class="col-12 productes">
<div class="producte1">
<div class="caixa">
<div class="caixa-img">
<img alt="" src="imgExplora/imgCarrousel/herbicida.jpg">
<div class="overlay">
Comprar
</div>
<div class="tipo">
<a href="#">
<h3>HERBICIDA</h3>
</a>
</div>
55€
</div>
<div class="info">
<span class="descripcio">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span>
</div>
</div>
</div>
</div>
if you use boostrap framework
you can use the bootstrap column and row.
<!-- language: lang-html -->
<div class="row">
<div class="col-6 productes">
<div class="producte1">
<div class="caixa">
<div class="caixa-img">
<img alt="" src="imgExplora/imgCarrousel/herbicida.jpg">
<div class="overlay">
Comprar
</div>
</div>
<div class="col-6">
<div class="tipo">
<a href="#">
<h3>HERBICIDA</h3>
</a>
<!--
<div class="rating">
<span>☆</span><span>☆</span><span>☆</span><span>☆</span><span>☆</span>
</div>-->
</div>
55€
</div>
<div class="info">
<span class="descripcio">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span>
</div>
</div>
</div>
</div>
</div>
<!-- end snippet -->
You have too much nested divs that dont need to be there, just making it more complex.
Also, your text is going outside your div borders, this is not a good thing.
You can move your text next to the image by using flex.
You always apply flex on a parent of the element that you want to move around (in this case, div with a picture, and div with a text).
So you are going to apply flex to a div that holds both of those divs (div with image, and div with text).
Here is my solution to this problem on a simple example, it should help you :
https://codepen.io/Juka99/pen/YzGVQyv

Setting modals size to 100%

I have created a modal inside a button-container which utilizes some flex display elements.
The problem occurs when I want to size the .modal-mask to a 100% of width/height to the whole page (body) size which is my goal here, I can't seem to get it to adjust properly without disturbing my button-container elements.
In short, I want the inner div .modal-mask to be sized 100% to the body
Project Fiddle: https://jsfiddle.net/est857q0/
HTML:
<ul id="button-container">
<li>
<a id="html-modal-button" #click="showModal = 'html-modal'">
<img class="htmllogo" src="http://sweettutos.com/wp-content/uploads/2015/12/placeholder.png">
</a>
<htmlmodal v-if="showModal === 'html-modal'" #close="showModal = false"></htmlmodal>
</li>
<li>
<a id="cs-modal-button" #click="showModal = 'cs-modal'">
<img class="csharplogo" src="http://sweettutos.com/wp-content/uploads/2015/12/placeholder.png">
</a>
<csmodal v-if="showModal === 'cs-modal'" #close="showModal = false"></csmodal>
</li>
</ul>
<!-- MODAL SECTION -->
<script type="text/x-template" id="html-modal-template">
<transition name="html-modal">
<div class="modal-mask">
<div class="modal-wrapper">
<div class="modal-container">
<div class="modal-content">
<slot name="body">
<button class="modal-default-button" #click="$emit('close')">HTML CLOSE</button>
</slot>
</div>
</div>
</div>
</div>
</transition>
</script>
<script type="text/x-template" id="cs-modal-template">
<transition name="cs-modal">
<div class="modal-mask">
<div class="modal-wrapper">
<div class="modal-container">
<div class="modal-content">
<slot name="body">
<button class="modal-default-button" #click="$emit('close')">CS CLOSE</button>
</slot>
</div>
</div>
</div>
</div>
</transition>
</script>
CSS:
/*Global*/
html {
margin-right: calc(100% - 100vw);
/*overflow: hidden;*/
}
body {
margin: 0 auto;
background-image: url('../images/wallpaper.jpg');
font-family: 'Josefin Sans', sans-serif;
}
*::selection {
background-color: red;
}
/*Header*/
h1 {
text-transform: uppercase;
width: 100%;
font-size: 9vw;
text-align: center;
margin-top: 4vh;
}
/*Containers*/
#button-container {
padding: 0;
margin: 0;
list-style: none;
display: flex;
-webkit-flex-flow: row wrap;
justify-content: space-around;
margin-top: 40vh;
margin-left: 50vw;
transform: translate(-50%, -70%);
width: 90vw;
height: 45vh;
align-items: baseline;
background: linear-gradient(to right, transparent 0%, #fff 33%, #fff 66%, transparent 100%);
}
#button-container li {
position: relative;
display: inline-block;
cursor: pointer;
}
#button-container .html-text-block,
.cs-text-block {
position: absolute;
bottom: 4px;
width: 100%;
height: 30%;
box-sizing: border-box;
background-color: #fff;
padding-left: 5px;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
transition: box-shadow 0.5s cubic-bezier(.25, .8, .25, 1), transform 0.5s cubic-bezier(.25, .8, .25, 1);
}
#button-container .htmllogo,
#button-container .csharplogo {
width: 150px;
}
#button-container {
border: 1px solid #000;
}
img:hover {
transform: scale(1.1);
}
/* THE MODAL CSS SECTION */
/*Main Modal container*/
.modal-mask {
position: fixed;
z-index: 9998;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .5);
display: table;
transition: opacity .3s ease;
}
.modal-wrapper {
display: table-cell;
vertical-align: middle;
}
.modal-container {
width: 300px;
margin: 0px auto;
padding: 20px 30px;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
transition: all .3s ease;
font-family: Helvetica, Arial, sans-serif;
}
.modal-content {
margin: 20px 0;
}
I attempted to set the button-container too 100% : https://jsfiddle.net/est857q0/ yet this messes up the flow

Dealing with textarea height crossbrowser

I'm trying to absolute position a button underneath a textarea, I have some content next to the button I'd like to have it not push down.
html {
background: #1f252e;
color: white;
font-family: sans-serif;
}
.commentForm {
position: relative;
}
.textInput {
padding: 10px;
background: rgba(0, 0, 0, 0.08);
border: solid 1px rgba(255, 255, 255, 0.05);
position: relative;
border-radius: 2px;
height: 55px;
overflow: hidden;
z-index: 1;
}
.textInput__input {
color: white;
width: 100%;
resize: none;
font-size: 14px;
font-family: 'Roboto', sans-serif;
background: transparent;
margin: 0px;
outline: none;
border: none;
display: block;
}
.textInput:hover {
cursor: text;
background: rgba(255, 255, 255, 0.05);
}
.formField.hasErrors .wd-input {
border-color: #e43e22;
}
.wd-form__footer {
margin-top: 15px;
display: flex;
}
.formField__error {
margin-top: 15px;
font-size: 13px;
color: #e43e22;
}
.wd-button--primary {
background: rgba(0, 0, 0, 0.25);
height: 35px;
min-width: 50px;
padding: 10px;
position: relative;
border-radius: 2px;
overflow: hidden;
z-index: 1;
font-size: 14px;
}
.wd-button {
display: -webkit-inline-box;
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
display: inline-flex;
box-sizing: border-box;
}
.wd-form__status {
flex-grow: 1;
}
.commentForm__actions {
position: absolute;
top: 90px;
right: 0px;
}
<div class="commentForm wd-form">
<div class="form">
<div class="formField hasErrors" style="max-width: 100%;">
<div class="textInput wd-input ">
<textarea rows="3" class="textInput__input" placeholder="Type a comment..."></textarea>
</div>
<div class="formField__error">15 more characters to go...</div>
</div>
<div class="wd-form__footer">
<div class="wd-form__status">
<div class="formStatus"></div>
</div>
<div class="commentForm__actions wd-form__actions">
<a role="button" class="wd-button wd-button--primary">
<div class="wd-button__label">Post comment</div>
</a>
</div>
</div>
</div>
</div>
Now, in Firefox and Chrome I get very different results.
In Chrome the button is aligned properly:
But in firefox, the button is clipping with the textarea:
This is because the text area height is different in Firefox than it is in Chrome. How do I fix this?
I tend to stay away from position: absolute if I can. You can instead use float: right and a negative margin.
html {
background: #1f252e;
color: white;
font-family: sans-serif;
}
.commentForm {
position: relative;
}
.textInput {
padding: 10px;
background: rgba(0, 0, 0, 0.08);
border: solid 1px rgba(255, 255, 255, 0.05);
position: relative;
border-radius: 2px;
height: 55px;
overflow: hidden;
z-index: 1;
}
.textInput__input {
color: white;
width: 100%;
resize: none;
font-size: 14px;
font-family: 'Roboto', sans-serif;
background: transparent;
margin: 0px;
outline: none;
border: none;
display: block;
}
.textInput:hover {
cursor: text;
background: rgba(255, 255, 255, 0.05);
}
.formField.hasErrors .wd-input {
border-color: #e43e22;
}
.wd-form__footer {
margin-top: -15px;
}
.formField__error {
margin-top: 15px;
font-size: 13px;
color: #e43e22;
}
.wd-button--primary {
background: rgba(0, 0, 0, 0.25);
height: 35px;
min-width: 50px;
padding: 10px;
position: relative;
border-radius: 2px;
overflow: hidden;
z-index: 1;
font-size: 14px;
}
.wd-button {
display: -webkit-inline-box;
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
display: inline-flex;
box-sizing: border-box;
}
.wd-form__status {
flex-grow: 1;
}
.commentForm__actions {
position: absolute;
top: 90px;
right: 0px;
}
<div class="commentForm wd-form">
<div class="form">
<div class="formField hasErrors" style="max-width: 100%;">
<div class="textInput wd-input ">
<textarea rows="3" class="textInput__input" placeholder="Type a comment..."></textarea>
</div>
<div class="formField__error">15 more characters to go...</div>
</div>
<div class="wd-form__footer">
<div class="wd-form__status">
<div class="formStatus"></div>
</div>
<div class="commentForm__actions wd-form__actions">
<a role="button" class="wd-button wd-button--primary">
<div class="wd-button__label">Post comment</div>
</a>
</div>
</div>
</div>
</div>