I created a card using the bootstrap. Within that card I intend to insert a table with data.
My problem is that when reducing the screen (check responsiveness), the data in the table comes out of the card.
How can I solve this problem of mine, can someone help me?
Thanks
DEMO
.HTML
<div style="width:40%">
<div class="card">
<div class="card-header header">
<h1>My Table</h1>
</div>
<table class="card-table table-borderless myTable" style="overflow-y: auto; overflow-x: auto;">
<thead>
<tr>
<th scope="col tableTitles">Title</th>
<th scope="col tableTitles">Name</th>
<th scope="col tableTitles">ID</th>
<th scope="col tableTitles">Street</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let pr of Data; let a = index;" class="tableColor">
<td class="tableTitles">
{{pr.title}}
</td>
<td class="tableTitles">
{{pr.name}}
</td>
<td class="tableTitles">
{{pr.id}}
</td>
<td class="tableTitles">
{{pr.street}}
</td>
</tr>
</tbody>
</table>
</div>
</div>
.CS
.card {
margin-top: 16px;
margin-left: 16px;
height: 400px;
margin-right: 16px;
background: #FFFFFF 0% 0% no-repeat padding-box;
box-shadow: 0px 3px 20px #BCBCCB47;
border-radius: 8px;
opacity: 1;
border: 2px solid red;
}
.header {
width: 100%;
height: 40px;
background: #ECF2F9 0% 0% no-repeat padding-box;
border-radius: 8px 8px 0px 0px;
}
.header h1 {
text-align: center;
font-family: 'Noto Sans', sans-serif;
font-size: 14px;
letter-spacing: 0;
color: #4D4F5C;
}
Problem
Add
word-break: break-all;
to <table> in CSS and it will break words if necessary.
.card {
margin-top: 16px;
margin-left: 16px;
height: 400px;
margin-right: 16px;
background: #FFFFFF 0% 0% no-repeat padding-box;
box-shadow: 0px 3px 20px #BCBCCB47;
border-radius: 8px;
opacity: 1;
border: 2px solid red;
}
.header {
width: 100%;
height: 40px;
background: #ECF2F9 0% 0% no-repeat padding-box;
border-radius: 8px 8px 0px 0px;
}
.header h1 {
text-align: center;
font-family: 'Noto Sans', sans-serif;
font-size: 14px;
letter-spacing: 0;
color: #4D4F5C;
}
.card-table {
word-break: break-all;
}
<div _ngcontent-qii-c0="" style="width:20%">
<div _ngcontent-qii-c0="" class="card">
<div _ngcontent-qii-c0="" class="card-header header">
<h1 _ngcontent-qii-c0="">My Table</h1>
</div>
<table _ngcontent-qii-c0="" class="card-table table-borderless myTable" style="overflow-y: auto; overflow-x: auto;">
<thead _ngcontent-qii-c0="">
<tr _ngcontent-qii-c0="">
<th _ngcontent-qii-c0="" scope="col tableTitles">Title</th>
<th _ngcontent-qii-c0="" scope="col tableTitles">Name</th>
<th _ngcontent-qii-c0="" scope="col tableTitles">ID</th>
<th _ngcontent-qii-c0="" scope="col tableTitles">Street</th>
</tr>
</thead>
<tbody _ngcontent-qii-c0="">
<tr _ngcontent-qii-c0="" class="tableColor">
<td _ngcontent-qii-c0="" class="tableTitles"> asdasdad </td>
<td _ngcontent-qii-c0="" class="tableTitles"> asdasdas assd </td>
<td _ngcontent-qii-c0="" class="tableTitles"> 123123 </td>
<td _ngcontent-qii-c0="" class="tableTitles"> asdsadasdcas asdsad </td>
</tr>
</tbody>
</table>
</div>
</div>
I squeezed it a bit to show the result and used generated HTML from your demo, cause it's a CSS problem, so we don't need Angular here.
Related
I'm a student learning HTML and CSS. For a school project we need to make a simple game and I'm currently working on the design of the game lobby.
I wanted to add a moving smoke/fog overlay on top of my background but behind my tables, buttons and everything so I searched for some tutorials and was able to implement this. The only problem I have is that the background with the smoke is underneath the rest of my code. I tried searching for the problem myself but wasn't able to find it.
Here are the fog images
Here is a picture:
It would be amazing if someone could help me find the problem and how to fix this issue!
Here is the DEMO
#font-face{
src: url("images/font.otf");
font-family: lobbyfont;
}
.quick_game_button{
margin-left: 7%;
margin-top: 60px;
padding: 5px;
width: 240px;
border: 4px solid black;
height: 80px;
background-image: url("images/dirtyclothes3.jpg");
background-size: cover;
border-radius: 10px;
z-index: 3;
}
.quick_game_text{
font-family: lobbyfont, sans-serif;
font-size: 40px;
margin-top: 17px;
margin-left: 21px;
z-index: 3;
}
.quick_game_text:hover {
text-decoration: underline;
text-underline-offset: 2px;
cursor: pointer;
}
.lobby_title{
font-family: lobbyfont, sans-serif;
font-size: 100px;
margin-top: 40px;
margin-left: 7%;
letter-spacing: 1px;
width: 250px;
margin-bottom: 10px;
z-index: 3;
}
body{
font-family: sans-serif;
margin: 0;
padding: 0;
}
article.background_music{
background: rgba(43,45,47,.7);
border: solid black 2px;
width: 120px;
height: 40px;
position: absolute;
top: 15px;
right: 30px;
}
p.music_text{
font-family: "lobbyfont", sans-serif;
font-weight: bolder;
padding-left: 4px;
display: inline;
letter-spacing: 1px;
z-index: 3;
}
#sound_button{
margin-top: 10px;
padding-left: 20px;
display: inline;
z-index: 3;
}
.online_players_table{
border: 3px solid black;
margin-left: 40%;
margin-top: -215px;
width: 250px;
height: 380px;
border-collapse: collapse;
z-index: 3;
}
.friends_table{
border: 3px solid black;
margin-left: 70%;
margin-top: -421px;
width: 250px;
height: 384px;
border-collapse: collapse;
z-index: 3;
}
.caption_titel{
font-family: lobbyfont, sans-serif;
font-size: 30px;
}
.caption_friends{
font-family: lobbyfont, sans-serif;
font-size: 30px;
letter-spacing: 1px;
}
tbody tr:nth-child(odd) {
background-color: rgba(0,0,0,0.70);
color: dimgrey;
}
tbody tr:nth-child(even) {
background-color: rgba(43,45,47,0.70);
}
.add_friend_text{
margin: 3px;
width: 40px;
font-family: lobbyfont, sans-serif;
color: black;
letter-spacing: 1px;
border: 1.5px solid black;
background: rgb(43, 45, 47);
background-size: contain;
border-radius: 10px;
}
.add_friend_text:hover{
cursor: pointer;
}
.invite_friend_text{
margin: 3px;
width: 58px;
font-family: lobbyfont, sans-serif;
color: black;
letter-spacing: 1px;
border: 1.5px solid black;
background: rgb(43, 45, 47);
background-size: contain;
border-radius: 10px;
}
.invite_friend_text:hover{
cursor: pointer;
}
th{
font-family: lobbyfont, sans-serif;
letter-spacing: 1px;
}
.absolute-bg {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: url("images/1989118_auto_x2.jpg");
background-position: 50%;
background-repeat: no-repeat;
background-size: cover;
overflow: hidden;
z-index: 2;
}
.fog {
position: relative;
height: 100vh;
width: 100%;
background: #fff;
z-index: 2;
}
.fog-container {
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
z-index: 2;
}
.fog-img {
position: absolute;
height: 100vh;
width: 300vw;
z-index: 2;
}
.fog-img-first {
background: url("images/fog-1.png");
background-repeat: repeat-x;
background-size: contain;
background-position: center;
animation: marquee 60s linear infinite;
z-index: 2;
}
.fog-img-second {
background: url("images/fog-2.png");
background-repeat: repeat-x;
background-size: contain;
background-position: center;
animation: marquee 30s linear infinite;
z-index: 2;
}
#keyframes marquee {
0% {
transform: translate3d(0, 0, 0);
}
100% {
transform: translate3d(-200vw, 0, 0);
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="test.css">
<title>test</title>
</head>
<body>
<!--lobby title-->
<p class="lobby_title">LOBBY</p>
<!--quick game button-->
<section class="quick_game_button">
<p class="quick_game_text" id="quick_game_Button">Quick Game</p>
</section>
<!--online players table-->
<table class="online_players_table">
<caption class="caption_titel">Online Players</caption>
<tr>
<th style="width: 75%"></th>
<th><p class="add_friend_text">add</p></th>
</tr>
<tr>
<th style="width: 75%">player 2</th>
<th><p class="add_friend_text">add</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="add_friend_text">add</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="add_friend_text">add</p></th>
</tr>
<tr>
<th style="width: 75%">player 5</th>
<th><p class="add_friend_text">add</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="add_friend_text">add</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="add_friend_text">add</p></th>
</tr>
<tr>
<th style="width: 75%">player 8</th>
<th><p class="add_friend_text">add</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="add_friend_text">add</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="add_friend_text">add</p></th>
</tr>
<tr>
<th style="width: 75%">player 11</th>
<th><p class="add_friend_text">add</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="add_friend_text">add</p></th>
</tr>
</table>
<!--friends table-->
<table class="friends_table">
<caption class="caption_friends">Friends</caption>
<tr>
<th style="width: 75%"></th>
<th><p class="invite_friend_text">invite</p></th>
</tr>
<tr>
<th style="width: 75%">friend2</th>
<th><p class="invite_friend_text">invite</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="invite_friend_text">invite</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="invite_friend_text">invite</p></th>
</tr>
<tr>
<th style="width: 75%">friend 5</th>
<th><p class="invite_friend_text">invite</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="invite_friend_text">invite</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="invite_friend_text">invite</p></th>
</tr>
<tr>
<th style="width: 75%">friend 8</th>
<th><p class="invite_friend_text">invite</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="invite_friend_text">invite</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="invite_friend_text">invite</p></th>
</tr>
<tr>
<th style="width: 75%">friend 11</th>
<th><p class="invite_friend_text">invite</p></th>
</tr>
<tr>
<th style="width: 75%"></th>
<th><p class="invite_friend_text">invite</p></th>
</tr>
</table>
<!--background music script-->
<article>
<script type="text/javascript">
function playpause() {
let snd = document.getElementById("sound");
let snd_btn = document.getElementById("sound_button");
snd.muted = !snd.muted; if(snd.muted){ snd_btn.innerHTML = "<img alt='Pause The Music' title='Music Paused' src='https://cdn3.iconfinder.com/data/icons/eightyshades/512/30_Sound_off-24.png' />"; } else{ snd_btn.innerHTML = "<img alt='Play The Music' title='Music Playing' src='https://cdn3.iconfinder.com/data/icons/eightyshades/512/29_Sound_alt-24.png' />"; } }
</script>
<audio autoplay loop id="sound" src="music/[HQ 1080p]Call of Duty Black Ops Multiplayer Menu Music + Download Link (mp3cut.net).mp3" type="audio/mp3"></audio>
</article>
<article class="background_music">
<p class="music_text">MUSIC</p><div id='sound_button' onClick="playpause()"><img title='Music Playing' alt='Play The Music' src='https://cdn3.iconfinder.com/data/icons/eightyshades/512/29_Sound_alt-24.png'/></div>
</article>
<!--fog background-->
<section class="fog">
<div class="absolute-bg"></div>
<div class="fog-container">
<div class="fog-img fog-img-first"></div>
<div class="fog-img fog-img-second"></div>
</div>
</section>
</body>
</html>
Disclaimer: novice here so take this with a pinch of salt.
I've provided a solution below that certainly isn't the most elegant but will help you on your way without altering too much of your code.
We can take the section of class 'fog' out entirely for the time being to simplify things a little.
We then take the div of class 'absolute-bg' and place this immediately below the body, making sure that all of your remaining elements are within this div and therefore (visually) 'on top' of your background.
We then set the 'absolute-bg' class to have a lower z-index than everything else (e.g. -1).
Next, we can take the div of 'fog-container' and give it two simple CSS properties: position: fixed; top: 0;
This removes the element from the Document flow and places it in a fixed position relative to the browser window, in this case, top: 0.
Finally, you want to be able to click-through your div 'fog-container' which now sits 'on-top' of everything else when rendered, therefore, we can add these two properties to .fog-container: pointer-events: none; touch-action: none;
Hope this helps. Elegant, no? A push in the right direction? Hopefully!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="./test.css">
<title>test</title>
</head>
<body>
<!-- Your fog section is still here but I've commented it out -->
<!-- <section class="fog"></section> -->
<div class="absolute-bg">
<!--lobby title-->
<p class="lobby_title">LOBBY</p>
<!--quick game button-->
<section class="quick_game_button">
<p class="quick_game_text" id="quick_game_Button">Quick Game</p>
</section>
<!--online players table-->
<table class="online_players_table">
<caption class="caption_titel">Online Players</caption>
<tr>
<th style="width: 75%"></th>
<th>
<p class="add_friend_text">add</p>
</th>
</tr>
<tr>
<th style="width: 75%">player 2</th>
<th>
<p class="add_friend_text">add</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="add_friend_text">add</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="add_friend_text">add</p>
</th>
</tr>
<tr>
<th style="width: 75%">player 5</th>
<th>
<p class="add_friend_text">add</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="add_friend_text">add</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="add_friend_text">add</p>
</th>
</tr>
<tr>
<th style="width: 75%">player 8</th>
<th>
<p class="add_friend_text">add</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="add_friend_text">add</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="add_friend_text">add</p>
</th>
</tr>
<tr>
<th style="width: 75%">player 11</th>
<th>
<p class="add_friend_text">add</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="add_friend_text">add</p>
</th>
</tr>
</table>
<!--friends table-->
<table class="friends_table">
<caption class="caption_friends">Friends</caption>
<tr>
<th style="width: 75%"></th>
<th>
<p class="invite_friend_text">invite</p>
</th>
</tr>
<tr>
<th style="width: 75%">friend2</th>
<th>
<p class="invite_friend_text">invite</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="invite_friend_text">invite</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="invite_friend_text">invite</p>
</th>
</tr>
<tr>
<th style="width: 75%">friend 5</th>
<th>
<p class="invite_friend_text">invite</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="invite_friend_text">invite</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="invite_friend_text">invite</p>
</th>
</tr>
<tr>
<th style="width: 75%">friend 8</th>
<th>
<p class="invite_friend_text">invite</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="invite_friend_text">invite</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="invite_friend_text">invite</p>
</th>
</tr>
<tr>
<th style="width: 75%">friend 11</th>
<th>
<p class="invite_friend_text">invite</p>
</th>
</tr>
<tr>
<th style="width: 75%"></th>
<th>
<p class="invite_friend_text">invite</p>
</th>
</tr>
</table>
<!--background music script-->
<article>
<script type="text/javascript">
function playpause() {
let snd = document.getElementById("sound");
let snd_btn = document.getElementById("sound_button");
snd.muted = !snd.muted;
if (snd.muted) {
snd_btn.innerHTML = "<img alt='Pause The Music' title='Music Paused' src='https://cdn3.iconfinder.com/data/icons/eightyshades/512/30_Sound_off-24.png' />";
} else {
snd_btn.innerHTML = "<img alt='Play The Music' title='Music Playing' src='https://cdn3.iconfinder.com/data/icons/eightyshades/512/29_Sound_alt-24.png' />";
}
}
</script>
<audio autoplay loop id="sound" src="music/[HQ 1080p]Call of Duty Black Ops Multiplayer Menu Music + Download Link (mp3cut.net).mp3" type="audio/mp3"></audio>
</article>
<article class="background_music">
<p class="music_text">MUSIC</p>
<div id='sound_button' onClick="playpause()"><img title='Music Playing' alt='Play The Music' src='https://cdn3.iconfinder.com/data/icons/eightyshades/512/29_Sound_alt-24.png' /></div>
</article>
<!--fog background-->
<div class="fog-container">
<div class="fog-img fog-img-first"></div>
<div class="fog-img fog-img-second"></div>
</div>
</div>
</section>
</body>
</html>
#font-face{
src: url("images/font.otf");
font-family: lobbyfont;
}
.quick_game_button{
margin-left: 7%;
margin-top: 60px;
padding: 5px;
width: 240px;
border: 4px solid black;
height: 80px;
background-image: url("images/dirtyclothes3.jpg");
background-size: cover;
border-radius: 10px;
z-index: 3;
}
.quick_game_text{
font-family: lobbyfont, sans-serif;
font-size: 40px;
margin-top: 17px;
margin-left: 21px;
z-index: 3;
}
.quick_game_text:hover {
text-decoration: underline;
text-underline-offset: 2px;
cursor: pointer;
}
.lobby_title{
font-family: lobbyfont, sans-serif;
font-size: 100px;
margin-top: 40px;
margin-left: 7%;
letter-spacing: 1px;
width: 250px;
margin-bottom: 10px;
z-index: 3;
}
body{
font-family: sans-serif;
margin: 0;
padding: 0;
}
article.background_music{
background: rgba(43,45,47,.7);
border: solid black 2px;
width: 120px;
height: 40px;
position: absolute;
top: 15px;
right: 30px;
}
p.music_text{
font-family: "lobbyfont", sans-serif;
font-weight: bolder;
padding-left: 4px;
display: inline;
letter-spacing: 1px;
z-index: 3;
}
#sound_button{
margin-top: 10px;
padding-left: 20px;
display: inline;
z-index: 3;
}
.online_players_table{
border: 3px solid black;
margin-left: 40%;
margin-top: -215px;
width: 250px;
height: 380px;
border-collapse: collapse;
z-index: 3;
}
.friends_table{
border: 3px solid black;
margin-left: 70%;
margin-top: -421px;
width: 250px;
height: 384px;
border-collapse: collapse;
z-index: 3;
}
.caption_titel{
font-family: lobbyfont, sans-serif;
font-size: 30px;
}
.caption_friends{
font-family: lobbyfont, sans-serif;
font-size: 30px;
letter-spacing: 1px;
}
tbody tr:nth-child(odd) {
background-color: rgba(0,0,0,0.70);
color: dimgrey;
}
tbody tr:nth-child(even) {
background-color: rgba(43,45,47,0.70);
}
.add_friend_text{
margin: 3px;
width: 40px;
font-family: lobbyfont, sans-serif;
color: black;
letter-spacing: 1px;
border: 1.5px solid black;
background: rgb(43, 45, 47);
background-size: contain;
border-radius: 10px;
}
.add_friend_text:hover{
cursor: pointer;
}
.invite_friend_text{
margin: 3px;
width: 58px;
font-family: lobbyfont, sans-serif;
color: black;
letter-spacing: 1px;
border: 1.5px solid black;
background: rgb(43, 45, 47);
background-size: contain;
border-radius: 10px;
}
.invite_friend_text:hover{
cursor: pointer;
}
th{
font-family: lobbyfont, sans-serif;
letter-spacing: 1px;
}
.absolute-bg {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: url("images/1989118_auto_x2.jpg");
background-position: 50%;
background-repeat: no-repeat;
background-size: cover;
overflow: hidden;
z-index: -1;
}
/* not using this for now */
/* .fog {
position: relative;
height: 100vh;
width: 100%;
background: #fff;
z-index: 2; */
.fog-container {
position: fixed;
top: 0;
width: 100%;
height: 120%;
overflow: hidden;
z-index: 2;
pointer-events: none;
touch-action: none;
}
.fog-img {
position: absolute;
height: 100%;
width: 300vw;
z-index: 2;
}
.fog-img-first {
background: url("images/fog-1.png");
background-repeat: repeat-x;
background-size: contain;
background-position: center;
-webkit-animation: marquee 60s linear infinite;
animation: marquee 60s linear infinite;
z-index: 2;
}
.fog-img-second {
background: url("images/fog-2.png");
background-repeat: repeat-x;
background-size: contain;
background-position: center;
-webkit-animation: marquee 30s linear infinite;
animation: marquee 30s linear infinite;
z-index: 2;
}
#-webkit-keyframes marquee {
0% {
transform: translate3d(0, 0, 0);
}
100% {
transform: translate3d(-200vw, 0, 0);
}
}
#keyframes marquee {
0% {
transform: translate3d(0, 0, 0);
}
100% {
transform: translate3d(-200vw, 0, 0);
}
}
I created a card using the bootstrap. Within that card, I intend to insert a table with data.
My problem is that when reducing the screen (check responsiveness), the data in the table comes out of the card.
How can I make this so that the table doesn't extend out and instead it has a horizontal scroll to it, can someone help me?
Thanks
DEMO
.card {
margin-top: 16px;
margin-left: 16px;
height: 400px;
margin-right: 16px;
background: #FFFFFF 0% 0% no-repeat padding-box;
box-shadow: 0px 3px 20px #BCBCCB47;
border-radius: 8px;
opacity: 1;
border: 2px solid red;
}
.header {
width: 100%;
height: 40px;
background: #ECF2F9 0% 0% no-repeat padding-box;
border-radius: 8px 8px 0px 0px;
}
.header h1 {
text-align: center;
font-family: 'Noto Sans', sans-serif;
font-size: 14px;
letter-spacing: 0;
color: #4D4F5C;
}
<div style="width:40%">
<div class="card">
<div class="card-header header">
<h1>My Table</h1>
</div>
<table class="card-table table-borderless myTable" style="overflow-y: auto; overflow-x: auto;">
<thead>
<tr>
<th scope="col tableTitles">Title</th>
<th scope="col tableTitles">Name</th>
<th scope="col tableTitles">ID</th>
<th scope="col tableTitles">Street</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let pr of Data; let a = index;" class="tableColor">
<td class="tableTitles">
{{pr.title}}
</td>
<td class="tableTitles">
{{pr.name}}
</td>
<td class="tableTitles">
{{pr.id}}
</td>
<td class="tableTitles">
{{pr.street}}
</td>
</tr>
</tbody>
</table>
</div>
</div>
You can use overflow-x: scroll; and move the card header to outside of the card.
.card {
margin-top: 16px;
margin-left: 16px;
height: 400px;
margin-right: 16px;
background: #FFFFFF 0% 0% no-repeat padding-box;
box-shadow: 0px 3px 20px #BCBCCB47;
border-radius: 8px;
opacity: 1;
border: 2px solid red;
overflow-x:scroll;
}
.header {
width: 100%;
height: 40px;
background: #ECF2F9 0% 0% no-repeat padding-box;
border-radius: 8px 8px 0px 0px;
}
.header h1 {
text-align: center;
font-family: 'Noto Sans', sans-serif;
font-size: 14px;
letter-spacing: 0;
color: #4D4F5C;
}
<div style="width:40%">
<div class="card-header header">
<h1>My Table</h1>
</div>
<div class="card">
<table class="card-table table-borderless myTable" style="overflow-y: auto; overflow-x: auto;">
<thead>
<tr>
<th scope="col tableTitles">Title</th>
<th scope="col tableTitles">Name</th>
<th scope="col tableTitles">ID</th>
<th scope="col tableTitles">Street</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let pr of Data; let a = index;" class="tableColor">
<td class="tableTitles">
{{pr.title}}
</td>
<td class="tableTitles">
{{pr.name}}
</td>
<td class="tableTitles">
{{pr.id}}
</td>
<td class="tableTitles">
{{pr.street}}
</td>
</tr>
</tbody>
</table>
</div>
</div>
I was trying to set calendar in table structure but I don't know how to set caption at the top of the table.
Also I can't change the table structure. I want it to look like below:
.calendar_wrap table {
width: 100%;
}
.calendar_wrap #wp-calendar thead th {
font-weight: 500;
color: #45515a;
font-size: 20px;
line-height: 28px;
}
.calendar_wrap #wp-calendar tbody td {
font-weight: 400;
font-size: 24px;
line-height: 36px;
color: #5b666f;
}
.calendar_wrap #wp-calendar tfoot td a {
color: #3d9596;
font-weight: 500;
margin-top: 10px;
display: inline-block;
font-size: 22px;
line-height: 32px;
}
.calendar_wrap #wp-calendar tbody td a {
color: #EF9950;
}
.calender-box {
padding: 15px;
border: 1px solid #d4d9dd;
border-radius: 8px;
}
caption {
font-size: 30px;
line-height: 36px;
color: #007ab0;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<section class="calendar_wrap mt-5">
<div class="container">
<div class="row justify-content-center">
<div class="col-4 mt-4 calender-box">
<table id="wp-calendar">
<caption>February 2019</caption>
<thead>
<tr>
<th scope="col" title="Monday">M</th>
<th scope="col" title="Tuesday">T</th>
<th scope="col" title="Wednesday">W</th>
<th scope="col" title="Thursday">T</th>
<th scope="col" title="Friday">F</th>
<th scope="col" title="Saturday">S</th>
<th scope="col" title="Sunday">S</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3" id="prev">« Oct</td>
<td class="pad"> </td>
<td colspan="3" id="next" class="pad"> </td>
</tr>
</tfoot>
<tbody>
<tr>
<td colspan="4" class="pad"> </td><td>1</td><td>2</td><td>3</td>
</tr>
<tr>
<td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td>
</tr>
<tr>
<td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td>
</tr>
<tr>
<td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td>
</tr>
<tr>
<td id="today">25</td><td>26</td><td>27</td><td>28</td>
<td class="pad" colspan="3"> </td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
Add caption-side: top - for style specificity either make the selector #wp-calendar caption or add !important to the style - see demo below:
.calendar_wrap table {
width: 100%;
}
.calendar_wrap #wp-calendar thead th {
font-weight: 500;
color: #45515a;
font-size: 20px;
line-height: 28px;
}
.calendar_wrap #wp-calendar tbody td {
font-weight: 400;
font-size: 24px;
line-height: 36px;
color: #5b666f;
}
.calendar_wrap #wp-calendar tfoot td a {
color: #3d9596;
font-weight: 500;
margin-top: 10px;
display: inline-block;
font-size: 22px;
line-height: 32px;
}
.calendar_wrap #wp-calendar tbody td a {
color: #EF9950;
}
.calender-box {
padding: 15px;
border: 1px solid #d4d9dd;
border-radius: 8px;
}
caption {
font-size: 30px;
line-height: 36px;
color: #007ab0;
}
#wp-calendar caption { /* ADDED */
caption-side: top;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<section class="calendar_wrap mt-5">
<div class="container">
<div class="row justify-content-center">
<div class="col-4 mt-4 calender-box">
<table id="wp-calendar">
<caption>February 2019</caption>
<thead>
<tr>
<th scope="col" title="Monday">M</th>
<th scope="col" title="Tuesday">T</th>
<th scope="col" title="Wednesday">W</th>
<th scope="col" title="Thursday">T</th>
<th scope="col" title="Friday">F</th>
<th scope="col" title="Saturday">S</th>
<th scope="col" title="Sunday">S</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3" id="prev">« Oct</td>
<td class="pad"> </td>
<td colspan="3" id="next" class="pad"> </td>
</tr>
</tfoot>
<tbody>
<tr>
<td colspan="4" class="pad"> </td><td>1</td><td>2</td><td>3</td>
</tr>
<tr>
<td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td>
</tr>
<tr>
<td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td>
</tr>
<tr>
<td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td>
</tr>
<tr>
<td id="today">25</td><td>26</td><td>27</td><td>28</td>
<td class="pad" colspan="3"> </td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
I am trying to create a hover element that displays a table of data.
I am having trouble making the hover element stack above the main table.
I have tried several things, including fixing the position and adjusting the z-index but everything seems to break the formatting and position of the hover element (i.e it needs to be positioned relative to the text that is hovered over and needs to adjust in width and height).
Example: https://jsfiddle.net/f1hLrwvf/
span.own3 {
background: #FFFFFF;
opacity: 1;
border: 1px solid #DCDCDC;
color: #000000;
font-size: 12px;
height: auto;
width: auto;
min-width: 300px;
letter-spacing: 1px;
line-height: 14px;
position: absolute;
text-align: justify;
top: 20px;
left: 0px;
display: none;
padding: 2px 5px;
font-family: "Helvetica Neue", Arial, sans-serif;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1), 0 3px 10px 0 rgba(0, 0, 0, 0.09);
}
hover.own2 {
position: relative;
}
hover.own2:hover span {
display: block;
}
.table.hoverstatus>tbody>tr:first-child>th {
border: none;
}
<div style="padding:15px;">
<div class="shadow p-3 mb-5 bg-white rounded table-responsive" style="border: 1px solid #F0F0F0;font-family: 'Poppins', sans-serif;font-size:14px;">
<table id="example" class="table table-striped" width="100%">
<thead>
<tr>
<th>Feeling</th>
<th>Day</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Super
</td>
<td>1</td>
</tr>
<tr>
<td>
<hover class="own2">Great<span class="own3"><table class="table hoverstatus" id="innertable"><tr><th>Row1 Col1</th><th>Row1 Col2</th><th>Row1 Col3</th></tr><tr><td>Row2 Col1</td><td>Row2 Col2</td><td>Row2 Col3</td></tr></table></span></hover>
</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
</div>
Any guidance is greatly appreciated.
use position: absolute; instead position: relative;
Try code below:
span.own3 {
background: #FFFFFF;
opacity: 1;
border: 1px solid #DCDCDC;
color: #000000;
font-size: 12px;
height: auto;
width: auto;
min-width: 300px;
letter-spacing: 1px;
line-height: 14px;
position: absolute;
text-align: justify;
top: 20px;
left: 0px;
display: none;
padding: 2px 5px;
font-family: "Helvetica Neue", Arial, sans-serif;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1), 0 3px 10px 0 rgba(0, 0, 0, 0.09);
}
hover.own2 {
position: absolute;
}
hover.own2:hover span {
display: block;
}
.table.hoverstatus>tbody>tr:first-child>th {
border: none;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<div style="padding:15px;">
<div class="shadow p-3 mb-5 bg-white rounded table-responsive" style="border: 1px solid #F0F0F0;font-family: 'Poppins', sans-serif;font-size:14px;">
<table id="example" class="table table-striped" width="100%">
<thead>
<tr>
<th>Feeling</th>
<th>Day</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Super
</td>
<td>1</td>
</tr>
<tr>
<td>
<hover class="own2">Great<span class="own3"><table class="table hoverstatus" id="innertable"><tr><th>Row1 Col1</th><th>Row1 Col2</th><th>Row1 Col3</th></tr><tr><td>Row2 Col1</td><td>Row2 Col2</td><td>Row2 Col3</td></tr></table></span></hover>
</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
</div>
You need to change some html markup as well as css
span.own3 {
background: #FFFFFF;
opacity: 1;
border: 1px solid #DCDCDC;
color: #000000;
font-size: 12px;
height: auto;
width: auto;
min-width: 300px;
letter-spacing: 1px;
line-height: 14px;
position: absolute;
text-align: justify;
top: 100%; // Changed to percentage instead of px
left: 0px;
display: none;
padding: 2px 5px;
font-family: "Helvetica Neue", Arial, sans-serif;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1), 0 3px 10px 0 rgba(0, 0, 0, 0.09);
}
hover.own2 {
position: relative;
}
hover.own2:hover span {
display: block;
}
.table.hoverstatus>tbody>tr:first-child>th {
border: none;
}
.dd-label {
padding: 10px 0;
display: inline-block;
}
<div style="padding:15px;">
<div class="shadow p-3 mb-5 bg-white rounded table-responsive" style="border: 1px solid #F0F0F0;font-family: 'Poppins', sans-serif;font-size:14px;">
<table id="example" class="table table-striped" width="100%">
<thead>
<tr>
<th>Feeling</th>
<th>Day</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Super
</td>
<td>1</td>
</tr>
<tr>
<td>
<hover class="own2">
<!-- wrap this label in a span tag -->
<span class="dd-label">Great</span>
<!-- span tag ends -->
<span class="own3"><table class="table hoverstatus" id="innertable"><tr><th>Row1 Col1</th><th>Row1 Col2</th><th>Row1 Col3</th></tr><tr><td>Row2 Col1</td><td>Row2 Col2</td><td>Row2 Col3</td></tr></table></span></hover>
</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
</div>
Working fiddle here
Hope it will help you :)
I have the problem that the scroll bar appears disabled. What I want to achieve is static table header (that is why I used two tables) and a scrollable table body.
HTML:
<div id="segment-content">
<div class="table-header">
<table>
<thead>
<tr class="font-readable">
<th class="hashtag" align="center">#</th>
<th class="in">In</th>
<th class="out">Out</th>
<th class="duration">Duration</th>
<th class="filename">Filename</th>
<th class="unset">Unset</th>
<th class="preview">Preview</th>
<th class="public">Public</th>
</tr>
</thead>
</table>
</div>
<div class="table-body">
<table>
<tbody>
<tr class="font-readable">
<td class="hashtag">1</td>
<td class="in">10-10-2015 11:11:00</td>
<td class="out">10-10-2015 11:11:00</td>
<td class="duration">1800 seg</td>
<td class="filename">10-10-2015-11-11-00-10-10-2015-11-1200.mp4</td> <td class="unset">Unset</td>
<td class="preview">Preview</td>
<td class="public">Public</td>
</tr>
<tr class="font-readable">
<td class="hashtag">2</td>
<td class="in">10-10-2015 11:11:00</td>
<td class="out">10-10-2015 11:11:00</td>
<td class="duration">1800 seg</td>
<td class="filename">10-10-2015-11-11-00-10-10-2015-11-12-00.mp4</td>
<td class="unset">Unset</td>
<td class="preview">Preview</td>
<td class="public">Public</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
CSS
#segment-content {
/*margin-top: 455px;*/
margin-top: 470px;
margin-left: 65px;
margin-right: 65px;
background: #1F1F1F;
}
.table-body {
overflow-y: scroll;
height: 100%;
}
table {
width: 100%;
}
.font-readable {
font-family: Tahoma, Geneva, sans-serif;
font-size: 11px;
font-weight: bold;
text-align: center;
}
.hashtag {
width: 20px;
}
.in, .out {
width: 200px;
}
.duration {
width: 100px;
}
.filename {
width: 400px;
}
how can i fix this?