I made a list to test the overflow of a div. The problem is, the overflow dont works correct:
Instead of using the overflow scroll, it goes invisible through the div?
This is my html:
<div class="modelSamples">
<div id="samplesTitle">
SAMPLES
</div>
<div class="sampleList">
<div id="samples" *ngFor="let tape of sampeList">
<div id="sampleName"> {{tape.name}} </div>
<div id="samplePlay">
<mat-icon> play_circle </mat-icon>
</div>
</div>
</div>
</div>
</div>
CSS:
.modelSamples{
overflow-y: auto;
margin-top: 10px;
margin-left: 10px;
width: 30%;
height: 60%;
background-color: rgb(191 126 235 / 29%);
z-index: 1;
border-radius: 30px;
}
#samplesTitle{
display: flex;
font-family: Oswald;
width: 100%;
justify-content: center;
margin-top: 20px;
color: white;
font-size: 2rem;
padding-bottom: 15px;
}
#samples{
display: flex;
flex-direction: row;
font-family: Oswald;
color: white;
font-size: 20px;
margin-left: 20px;
justify-content: space-between;
}
#sampleName, #samplePlay{
padding-bottom: 10px;
}
#samplePlay{
padding-right: 30px;
}
I also tried it with using max-height for .sampleList but that also dont work
Related
I have a button inside a grid cell whose size is determined by font-size as em and padding as percentage.
I require the text of the button to not wrap.
Initially, I used <button type="button" id="log_out_button" data-action="manual_log_out">log out</button> but this produced an undesired result - it wrapped the text:
log
out
I added white-space: nowrap to the button to fix this but it made the button exceed its parent by 0.5cm, which decentralises my grid by the same amount.
To try fixing this knock-on problem, I changed the button to <input type="button" value="log out" id="log_out_button" data-action="manual_log_out">, to no avail.
I added box-sizing: border-box to the button, to no avail.
I experimented with grid-template-columns: auto auto auto; (third value), trying the various options listed Chrome's dev console, to no avail.
Prior to the navigation being a grid, it was a flexbox that had the same problem.
I want my site scalable so I can't set fixed values i.e. in pixels, and setting the percentage of the cell (grid-template-columns) still results in an offset/decentralisation.
How do I prevent my 'log out' button's text from wrapping and prevent it from exceeding its parent's width, such that I avoid the grid's decentralisation issue?
Problem code:
<html>
<head>
<style type="text/css">
body {
font-family: Arial;
background-color: white;
font-size: 1.5vh;
}
header {
height: 100%;
margin: auto;
height: 10.9%;
width: 100%;
}
nav {
margin: auto;
align-items: center;
justify-content: center;
height: 100%;
display: grid;
grid-template-columns: auto auto auto;
grid-gap: 2.5%;
}
nav a, nav a:visited {
text-decoration: none;
color: black;
}
#user_identity {
display: flex;
justify-content: center;
flex-flow: column;
align-items: flex-end;
}
#navigation_menu_wrapper {
height: 100%;
}
#navigation_menu {
flex: 1;
display: flex;
height: 100%;
align-items: center;
}
#navigation_menu div {
text-align: center;
padding-left: 15px;
padding-right: 15px;
font-size: 1.125em;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background-color: rgb(205, 255, 205);
border-right: 1px solid rgb(157, 189, 157);
}
#navigation_menu a {
display: block;
padding: 7px 12px 7px 12px;
border-radius: 3px;
cursor: pointer;
}
#log_out_wrapper {
display: flex;
justify-content: flex-start;
align-items: center;
height: 100%;
}
#username_label {
font-family: "Optima Bold";
font-size: 1.87em;
color: rgb(72, 160, 72);
}
#permanent_id_label {
font-size: 1em;
color: rgb(146, 146, 146);
font-weight: bold;
margin-left: 9px;
cursor: default;
}
#mobile_menu_control {
display: none;
}
#log_out_button {
padding-top: 7%;
padding-bottom: 8%;
border: none;
border-radius: 3px;
background-color: #8dc49d;
text-align: center;
padding-left: 12%;
padding-right: 12%;
font-size: 1.25em;
cursor: pointer;
}
</style>
</head>
<body>
<div id="wrapper">
<header>
<nav>
<div id="user_identity">
<div id="username_label">texthere</div>
<div id="permanent_id_label">#texthere</div>
</div>
<div id="navigation_menu_wrapper">
<button id="mobile_menu_control">menu</button>
<div id="navigation_menu">
<div>
link1
</div>
<div>
link2
</div>
<div>
link3
</div>
<div>
link4
</div>
<div>
link5
</div>
<div>
link6
</div>
</div>
</div>
<div id="log_out_wrapper">
<input type="button" value="log out" id="log_out_button" data-action="manual_log_out">
</div>
</nav>
</header>
<div id="content_wrapper"></div>
</div>
</body>
</html>
As suggested by commenters, applied the following jQuery/JavaScript fix:
logOutButtonWidth = 0;
$(document).ready(function() {
centraliseHeader();
$(window).resize(function() {
centraliseHeader();
});
});
function centraliseHeader() {
logOutButtonWidth = $("#log_out_button").outerWidth();
$("nav").css({
gridTemplateColumns: "auto auto " + logOutButtonWidth + "px"
});
}
I really don't know what I'm doing wrong here. I want the image inside the box to stay centered when the window shrinks. Furthermore, I would have thought that align-items: center; would work, but apparently not. The colors are only relevant for me, so I understand what's going on. I don't know if there is a solution for this either, but I hope so. And please ignore the naming and order of the individual classes, I couldn't do better ...:)
.megadiv {
max-width: 1600px;
margin: auto;
text-align: center;
}
.centerbox {
display: flex;
justify-content: space-between;
}
.left {
width: 64%;
background-color: red;
justify-content: space-between;
border: 2px solid gray;
display: flex;
}
.insideleft {
width: 20%;
background-color: yellow;
align-items: center;
text-align: center;
align-content: center;
}
.insideright {
width: 78%;
background-color: purple;
float: right;
padding-top: 2%;
text-align: left;
border-left: 2px ridge #ffa54f;
padding-left: 2%;
padding-bottom: 1%;
}
.picture {
width: 80%;
border-radius: 1%;
margin-top: 10%;
margin-bottom: 8%;
}
.right {
width: 34%;
border: 2px solid gray;
height: 20px;
}
h7 {
color: rgb(0, 153, 158);
font-size: large;
font-family: sans-serif;
}
.textpart {
margin-bottom: 0.5%;
}
<div class="megadiv">
<div class="centerbox">
<div class="left">
<div class="insideleft">
<h20>
<a href="">
<img class="picture" src="https://images-na.ssl-images-amazon.com/images/I/71hi8fWdX2L.jpg"> </a>
</h20>
</div>
<div class="insideright">
<h7>Headline</h7><br>
<h4>
<div class="textpart">Authors</div>
<div class="textpart">Views <a class="" href="">Chapter 2</a></div>
<div class="textpart">Genres: Action - Adventure - Comedy</div>
<div class="textpart">Rating: ⭐⭐⭐⭐⭐</div>
</h4>
</div>
<div class="right">
wawaeaweew
</div>
</div>
</div>
h4 and h20 are empty
You're pretty close to getting the image vertically aligned as you wanted. Try this out, and see if this works the way you would like:
.megadiv {
max-width: 1600px;
margin: auto;
text-align: center;
}
.centerbox {
display: flex;
justify-content: space-between;
}
.left {
width: 64%;
background-color: red;
justify-content: space-between;
border: 2px solid gray;
display: flex;
}
.insideleft {
display: flex;
width: 20%;
background-color: yellow;
align-items: center;
text-align: center;
align-content: center;
}
.insideright {
width: 78%;
background-color: purple;
float: right;
padding-top: 2%;
text-align: left;
border-left: 2px ridge #ffa54f;
padding-left: 2%;
padding-bottom: 1%;
}
.picture {
width: 80%;
border-radius: 1%;
margin-top: 10%;
margin-bottom: 8%;
}
.right {
width: 34%;
border: 2px solid gray;
height: 20px;
}
h7 {
color: rgb(0, 153, 158);
font-size: large;
font-family: sans-serif;
}
.textpart {
margin-bottom: 0.5%;
}
<div class="megadiv">
<div class="centerbox">
<div class="left">
<div class="insideleft">
<a href="">
<img class="picture" src="https://images-na.ssl-images-amazon.com/images/I/71hi8fWdX2L.jpg"> </a>
</div>
<div class="insideright">
<h7>Headline</h7><br>
<h4>
<div class="textpart">Authors</div>
<div class="textpart">Views <a class="" href="">Chapter 2</a></div>
<div class="textpart">Genres: Action - Adventure - Comedy</div>
<div class="textpart">Rating: ⭐⭐⭐⭐⭐</div>
</h4>
</div>
<div class="right">
wawaeaweew
</div>
</div>
</div>
I saw you used align-items: center; in the .insideleft CSS selector which is for aligning a container's children to the center like you want, you'll just want to make this a flexbox to make this work. To do this, simply add display: flex; to the .insideleft selector like in the example. I also removed the <h20> tag from the HTML as this is not valid or necessary.
As for the image shrinking down when the screen width is shrinked - this is because you're using percentages for the widths for all the containers and the image. If you want the image to stop shrinking after a certain point, you can add min-width: 80px; /* (this can be any number of pixels) */ to your .picture selector to make the image stop shrinking once it gets to a certain width of pixels.
Flexbox is super useful for position elements in CSS and I'd recommend looking into this more to have a better understanding. Check out this link here if you'd like an overview of the different flexbox CSS properties.
I am not 100% sure on your intent - Here I changed the class names a bit for clarity and adjusted the markup for a left-middle-right
Not a huge fan of % for padding and margin sizing myself (em feels more clear since it is based on the current font size)
Not strictly needed but I added the containing element class in a few places in CSS for clarity example: .left-pane .picture-container
.page-container {
max-width: 1600px;
text-align: center;
}
.container-box {
display: flex;
align-content: space-between;
}
.container-box .left-pane {
width: 20em;
display: flex;
align-items: center;
justify-content: center;
background-color: #FF0000;
border: 2px solid gray;
}
.left-pane .picture-container {
width: 30%;
background-color: yellow;
align-items: center; /* vertical */
align-content: center; /* horizontal */
}
.left-pane .picture-container .picture {
width: 80%;
border-radius: 1%;
margin-top: 10%;
margin-bottom: 8%;
}
.container-box .middle-pane {
width: 70em;
background-color: #FFDDDD;
padding-top: 2%;
padding-left: 2%;
padding-bottom: 1%;
border-left: 2px ridge #ffa54f;
}
.middle-pane .headline {
color: rgb(0, 153, 158);
font-size: 1.5em;
font-family: sans-serif;
margin-bottom: 1em;
background-color: #eeeeee;
}
.middle-pane .textpart {
margin-bottom: 0.5em;
}
.container-box .right-pane {
height: 20px;
border: 2px solid gray;
}
<div class="page-container">
<div class="container-box">
<div class="left-pane">
<div class="picture-container">
<div>
<a href="">
<img class="picture" src="https://images-na.ssl-images-amazon.com/images/I/71hi8fWdX2L.jpg"> </a>
</div>
</div>
</div>
<div class="middle-pane">
<div class="headline">Headline</div>
<h4>
<div class="textpart">Authors</div>
<div class="textpart">Views <a class="" href="">Chapter 2</a></div>
<div class="textpart">Genres: Action - Adventure - Comedy</div>
<div class="textpart">Rating: ⭐⭐⭐⭐⭐</div>
</h4>
</div>
<div class="right-pane">
wawaeaweew
</div>
</div>
</div>
I had an iframe element inside a div working just fine. I wanted to resize the iframe video but I couldn't centre it, so I added another div to contain both the div and the iframe. And after doing this, you couldn't click the video anymore.
Here's the chunk of code regarding this problem. As you will see, I already tried setting z-index values and pointer-events: none;.
#botNavBar {
height: auto;
padding-top: 50px;
padding-bottom: 100px;
padding-left: 150px;
padding-right: 150px;
position: relative;
background: black;
display: flex;
flex-direction: column;
z-index: -1;
align-items: center;
}
#videoResizer {
width: 60%;
z-index: 2;
pointer-events: none;
}
#videoContainer {
width: 100%;
position: relative;
padding-bottom: 56.25%;
align-items: center;
justify-content: center;
text-align: center;
z-index: 2;
pointer-events: none;
}
#trailerTwogether {
position: absolute;
display: block;
width: 100%;
height: 100%;
border-style: none;
z-index: 200000000000000;
}
#leftSide {
width: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
}
#contactInfo {
Font-Family: 'Raleway', Sans-Serif;
Font-Size: 16px;
color: rgb(214, 234, 248);
margin-bottom: 0px;
padding-top: 50px;
}
#contactMail {
Font-Family: 'Raleway', Sans-Serif;
Font-Size: 16px;
color: darkmagenta;
margin-bottom: 0px;
padding-top: 0px;
margin-top: 0px;
}
<div id="botNavBar">
<div id="videoResizer">
<div id="videoContainer">
<iframe id="trailerTwogether" src="https://www.youtube.com/embed/7VjyXe_d57E"> </iframe>
</div>
</div>
<div id="leftSide">
<p id=contactInfo>
Desarrollado por <b>Flaming Llama Games</b> para <b>PS4</b>
<br>
Lanzamiento: finales <b>2021</b>
</p>
<p id="contactMail">
contacto#flamingllamagames.com
</p>
</div>
</div>
https://jsfiddle.net/Als3rr/e7kqv4wd/
I removed the styles by adding 1 in id in all 3 divs of iframe.
I have added inline style for iframe
I have added "padding-top:100px;" for #leftSide
It worked fine [https://i.stack.imgur.com/O9BUt.png][1]
#leftSide {
width: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
padding-top:100px;
}
<div id="botNavBar1">
<div id="videoResizer1">
<div id="videoContainer1">
<iframe id="trailerTwogether" src="https://www.youtube.com/embed/7VjyXe_d57E" style="height:20%; width:20%"> </iframe>
</div>
</div>
<div id="leftSide">
<p id=contactInfo>
Desarrollado por <b>Flaming Llama Games</b> para <b>PS4</b>
<br>
Lanzamiento: finales <b>2021</b>
</p>
<p id="contactMail">
contacto#flamingllamagames.com
</p>
</div>
</div>
The main issue is that you have a z-index: -1; on the top level element (#botNavBar). This puts this div "behind" the body.
Also the pointer-events: none; you have added in an attempt to solve the issue are unfortunately causing it in another way, so those also need to be removed.
Other small issues:
Font-Family and Font-Size should be all lower-case
This snippet won't display the issue here as the iframe is blocked inside a StackOverflow snippet, but it will work in a real enviroment.
#botNavBar {
height: auto;
padding-top: 50px;
padding-bottom: 100px;
padding-left: 150px;
padding-right: 150px;
position: relative;
background: black;
display: flex;
flex-direction: column;
align-items: center;
}
#videoResizer {
width: 60%;
z-index: 2;
}
#videoContainer {
width: 100%;
position: relative;
padding-bottom: 56.25%;
align-items: center;
justify-content: center;
text-align: center;
z-index: 2;
}
#trailerTwogether {
position: absolute;
display: block;
width: 100%;
height: 100%;
border-style: none;
z-index: 200000000000000;
}
#leftSide {
width: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
}
#contactInfo {
font-family: 'Raleway', Sans-Serif;
font-size: 16px;
color: rgb(214, 234, 248);
margin-bottom: 0px;
padding-top: 50px;
}
#contactMail {
font-family: 'Raleway', Sans-Serif;
font-size: 16px;
color: darkmagenta;
margin-bottom: 0px;
padding-top: 0px;
margin-top: 0px;
}
<div id="botNavBar">
<div id="videoResizer">
<div id="videoContainer">
<iframe id="trailerTwogether" src="https://www.youtube.com/embed/7VjyXe_d57E"> </iframe>
</div>
</div>
<div id="leftSide">
<p id=contactInfo>
Desarrollado por <b>Flaming Llama Games</b> para <b>PS4</b>
<br> Lanzamiento: finales <b>2021</b>
</p>
<p id="contactMail">
contacto#flamingllamagames.com
</p>
</div>
</div>
I try to make a chat-app, now i'm trying to implement the cheats and when user click on one chat, styles must change and remain until the user focus it's gonna to another chat
In my example let's assume someone clicked on User 2. The chat changed style and now have the style that should have when someone open that chat. How can i make the style to stay like that until someone open another chat? I didn't find any css propriety or some react tricks.
.userChatBubbles {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 5%;
width: 100%;
height: 100%;
}
.allOfMessage {
width: 100%;
height: 20%;
display: flex;
flex-direction: row;
align-items: center;
margin-left: 13%;
margin-bottom: 1px;
}
.messageBubleNEWMSG {
display: flex;
flex-direction: row;
align-items: center;
width: 90%;
height: 80%;
font-size: 15px;
background: #1d1335;
opacity: 1;
border-radius: 2%;
padding-left: 4%;
margin-right: 10%;
font-family: 'Roboto', sans-serif;
}
.messageBuble {
display: flex;
flex-direction: row;
align-items: center;
width: 90%;
height: 80%;
font-family: 'Roboto', sans-serif;
font-size: 15px;
padding-left: 4%;
margin-right: 10%;
}
.photo {
background: green;
width: 45px;
height: 45px;
margin-top: 2%;
border-radius: 10%;
margin-right: 6%;
}
.messageBubleNEWMSG.personNameAndMsg.personName {
color: green !important;
margin-top: 200%;
}
.messageBuble .personNameAndMsg h3 {
color: #c2b4da;
font-family: 'Roboto', sans-serif;
font-weight: 100;
font-size: 15px;
}
.messageBuble .personNameAndMsg p {
color: #514b64;
margin-top: -8%;
/* margin-top: 1%; */
font-family: 'Roboto', sans-serif;
font-weight: 200;
}
.messageBubleNEWMSG .personNameAndMsg h3 {
color: #e1dbed;
font-family: 'Roboto', sans-serif;
font-weight: 200;
font-size: 15px;
}
.messageBubleNEWMSG .personNameAndMsg p {
color: #736f83;
margin-top: -8%;
font-family: 'Roboto', sans-serif;
font-weight: 500;
/* margin-top: 1%; */
}
.messageTime {
margin-left: auto;
color: #6e6d73;
}
<div class='userChatBubbles'>
<div class='allOfMessage'>
<div class='messageBuble'>
<div class='photo'></div>
<div class='personNameAndMsg'>
<h3>User</h3>
<p> When can we hangout?</p>
</div>
<div class='messageTime'>6m</div>
</div>
</div>
<div class='allOfMessage'>
<div class='messageBubleNEWMSG'>
<div class='photo'></div>
<div class='personNameAndMsg'>
<h3>User 2</h3>
<p> When can we hang out?</p>
</div>
<div class='messageTime'>6m</div>
</div>
</div>
<div class='allOfMessage'>
<div class='messageBuble'>
<div class='photo'></div>
<div class='personNameAndMsg'>
<h3>User 3</h3>
<p> When can we hangout?</p>
</div>
<div class='messageTime'>6m</div>
</div>
</div>
</div>
So I'm trying to make some bar signals to signify different components. I want to make the bar so that it covers the whole height of the text, no matter how many lines there are. How can I make so that the bar extends from the top to the bottom of the div?
Divider with a set height:
.divider {
display: inline-block;
height: 20px;
width: 3px;
position: relative;
border-radius: 30px;
background: #0099ff;
margin-left: 35px;
}
p {
margin-left: 5px;
font-size: 20px;
color: var(--font-color);
}
<div style="display: flex; align-items: center; ">
<div class="divider"></div><p>Messages</p>
</div>
<div style="display: flex; align-items: center; margin-top: -20px; ">
<div class="divider"></div><p>Messages <br> Test</p>
</div>
Divider with height set at 100%:
.divider {
display: inline-block;
height: 100%;
width: 3px;
position: relative;
border-radius: 30px;
background: #0099ff;
margin-left: 35px;
}
p {
margin-left: 5px;
font-size: 20px;
color: var(--font-color);
}
<div style="display: flex; align-items: center; ">
<div class="divider"></div><p>Messages</p>
</div>
<div style="display: flex; align-items: center; margin-top: -20px; ">
<div class="divider"></div><p>Messages <br> google</p>
</div>
Why not just use border-left on the p itself?
p {
border-left:6px solid #0099ff;
padding-left: 15px;
margin-left: 5px;
font-size: 20px;
color: var(--font-color);
}
p {
border-left:6px solid #0099ff;
padding-left: 15px;
margin-left: 5px;
font-size: 20px;
color: var(--font-color);
}
<div style="display: flex; align-items: center; ">
<div class="divider"></div><p>Messages</p>
</div>
<div style="display: flex; align-items: center; margin-top: -20px; ">
<div class="divider"></div><p>Messages <br> Testd
asd
as<br>dsadasdas
as<br>dsadasdas
as<br>dsadasdas
as<br>dsadasdas
</p>
</div>
you should set 'divider' to <p> tag and set its class to height '100%'.
<p class="divider2">Messages <br> Test</p>
.divider2 {
height:100%;
width: 3px;
position: relative;
border-radius: 30px;
background: #0099ff;
margin-left: 35px;
}
enter link description here
Thank you.
use min-height:100% instead of height:100% in .divider