I'm showing a member who has a higher rank. Based on that, I have to show the user image along with the username.
but I'm not able to align the image and text efficiently..The problem is some username consists of a longer number of characters. As a result, the username showed in a zig-zag position..
so far, I've tried
<table style="width: 100%; table-layout: fixed" class="table table-striped text-center">
<thead class='bg-dark' style='background-color: 3658DE'>
<tr>
<th><img src='../assets/img/gold.png'/>Rank</th>
<th><i class='fa fa-user mr-1' style='color: #F4B806'></i>Members</th>
</tr>
<tr>
<td>
1
</td>
<td>
<div class='text-center'>
<img src='images' alt='user dp' class=' img-fluid rounded-circle' style='height: 30px; width: 30px;' />
<span class='mr-1 '>#$username</span>
</div>
<td>
</tr>
</thead>
<tbody>
Expected output:
Rank Member
1 image Dravid
2 image Richard Nixon
3 image GrahamBell
4 image Mark twains
Output's getting:
Rank Member
1 image Dravid
2 image RichardNixon
3 image GrahamBell
4 image Mark twains
img {margin-right:10px;};
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Rank</th>
<th scope="col">Member</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td><img src="image"/>member</td>
</tr>
<tr>
<th scope="row">2</th>
<td><img src="image"/>anotherMember</td>
</tr>
<tr>
<th scope="row">3</th>
<td><img src="image"/>oneMoreMember</td>
</tr>
</tbody>
</table>
Please check your table markup, it doesn't seems to have any data in <tbody> . If you have to show the user image before the username place the <img/> inside the <td> tag just before the name of the member(in your case username). This will give you the alignment as per your need, no matter how long is the username provided that the size(mostly width) of all the images is same. I have included little CSS just to provide some space between all images and usernames. Also make sure this space remains constant for all images, if you wish to include it.
Your problem is that you are using the text-center class on each <tr>'s second <td> (to display the username). That's because your those are centered accordingly resulting in this bug:
In order to solve this you have to replace it with text-left like in this example. The same for the second <th>. In order to place your item more to the right, apply a padding-left, e.g., by adding Bootstrap's pl-5:
<table style="width: 100%; table-layout: fixed" class="table table-striped text-center">
<thead class='bg-dark' style='background-color: 3658DE'>
<tr>
<th><img src='https://via.placeholder.com/25'/> Rank</th>
<th class="text-left pl-5"><i class='fa fa-user mr-1' style='color: #F4B806'></i>Members</th>
</tr>
</thead>
<tbody>
<tr>
<td>
1
</td>
<td>
<div class='text-left pl-5'>
<img src='https://via.placeholder.com/150' alt='user dp' class='img-fluid rounded-circle' style='height: 30px; width: 30px;' />
<span class='mr-1 '>Dravid</span>
</div>
</td>
</tr>
<tr>
<td>
2
</td>
<td>
<div class='text-left pl-5'>
<img src='https://via.placeholder.com/150' alt='user dp' class='img-fluid rounded-circle' style='height: 30px; width: 30px;' />
<span class='mr-1 '>RichardNixon</span>
</div>
</td>
</tr>
<tr>
<td>
3
</td>
<td>
<div class='text-left pl-5'>
<img src='https://via.placeholder.com/150' alt='user dp' class='img-fluid rounded-circle' style='height: 30px; width: 30px;' />
<span class='mr-1 '>GrahamBell</span>
</div>
</td>
</tr>
</tbody>
</table>
You can find a running fiddle here, which produces the following table:
Related
I am using bootstrap 5.
I have a table and I need to display four images side by side. This seems to work on a large screen:
However, on a phone the images are shrunken and no longer visible:
How can I force the images to remain at least 16px even on phone screens? The table will have a horizontal scroll but that is ok.
Is there a better way to display 4 img tags in one td and force all of them to be on the same line? The only way I found to do it is by putting them in row and col divs.
Code:
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">Username</th>
<th scope="col">Match Predictions Made</th>
<th scope="col">Winner</th>
<th scope="col">Finals</th>
<th scope="col">Top 4</th>
<th scope="col">Points</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Marcipanas</th>
<td>5/36</td>
<td><img src="assets/flags/be.svg" class=" float-start flag-img" alt="be"></td>
<td>
<div class="row">
<div class="col"><img src="assets/flags/it.svg" class="flag-img" alt="it"></div>
<div class="col"><img src="assets/flags/cz.svg" class="flag-img" alt="cz"></div>
</div>
</td>
<td>
<div class="row">
<div class="col"><img src="assets/flags/be.svg" class="flag-img" alt="be"></div>
<div class="col"><img src="assets/flags/dk.svg" class="flag-img" alt="dk"></div>
<div class="col"><img src="assets/flags/fi.svg" class="flag-img" alt="fi"></div>
<div class="col"><img src="assets/flags/ru.svg" class="flag-img" alt="ru"></div>
</div>
</td>
<td>0</td>
</tr>
<tr>
<th scope="row">test3</th>
<td>0/36</td>
<td><img src="assets/flags/it.svg" class=" float-start flag-img" alt="it"></td>
<td class="text-muted">No prediction</td>
<td class="text-muted">No prediction</td>
<td>0</td>
</tr>
<tr>
<th scope="row">testing1</th>
<td>1/36</td>
<td class="text-muted">No prediction</td>
<td class="text-muted">No prediction</td>
<td class="text-muted">No prediction</td>
<td>0</td>
</tr>
<tr>
<th scope="row">test2</th>
<td>0/36</td>
<td class="text-muted">No prediction</td>
<td class="text-muted">No prediction</td>
<td class="text-muted">No prediction</td>
<td>0</td>
</tr>
</tbody>
</table>
</div>
EDIT
As John suggested bellow I tried to add nowrap instead of using row-col but that seems to have forced everything into separate lines.
Code:
<td>
<div class="no-wrap">
<img src="assets/flags/be.svg" class="flag-img" alt="be">
<img src="assets/flags/dk.svg" class="flag-img" alt="dk">
<img src="assets/flags/fi.svg" class="flag-img" alt="fi">
<img src="assets/flags/ru.svg" class="flag-img" alt="ru">
</div>
</td>
css:
.flag-img {
max-height: 32px;
min-height: 16px;
min-width: 16px;
}
.no-wrap {
flex-wrap: nowrap !important;
}
Image of results:
So bootstrap defaults .row to have flex-wrap: wrap; You can add this to your CSS for force it to stop wrapping:
.row {
flex-wrap: nowrap !important;
}
Though I'd might consider adding a new class to each row with the images and calling that class instead of just outright .row incase there are areas where you want it to wrap. But this code will work.
As for the shrinking issue, if you want your pictures to never be smaller than 16px you can add this code to your CSS:
.flag-img {
min-width: 16px;
}
currently i have table like these
<div class="col-md-4 col-sm-4 col-xs-6">
<table class="table">
<tr>
<td><span class="test2">S1</span></td>
<td class="pic" rowspan="2"><img src="images/image.jpg" alt=""> </td>
</tr>
<tr>
<th>
<span class="rub">hahahaha</span><br>
hahaha<br>
<span class="rub">ferix tom</span>
</th>
</tr>
<tr>
<td class="prof">
<script>
<!--
var birthday = "1980/11/03";
document.write(birthday converter(birthday));
//-->
</script>
</td>
</tr>
<tr>
<td class="prof">90</td>
</tr>
</table>
</div>
which produce table like this picture
how to produce ribbon on the S1 span
i tried using http://www.css3d.net/ribbon-generator/#preview
but it's not covering the table
what my boss wants, look like this
please help css master
found the answer, using these
<tr>
<td><span class="rub2"><br></span></td>
<p class="ribbon">this is ribbon</p>
<td class="pic" rowspan="4"><img src="images/image.jpg" alt=""> </td>
</tr>
https://jsfiddle.net/4xwzuqpn/3/
I need to set a link on a picture. I have to set it up in tables, which I did. But I cannot understand why the picture is linking in full width. That means the background color is also a link. That link should only be on the picture.
If it was a div tag it could be solved with a wrapper, but I do not know how to solve that within tables?
My Example
This is my code:
<body>
<table class="wrapper" align="center">
<tr>
<td class="wrapper-inner">
<!-- Row 1 -->
<table class="row collapse" >
<tbody>
<tr>
<th class="small-12 large-12 columns first">
<table>
<tr>
<th>
<img src="http://3.bp.blogspot.com/-Z4vZ7AsD6Bc/T_PNRK_9f2I/AAAAAAAAAH4/t3UZ3BQyqdE/s1600/shutterstock.jpg" alt="test" align="center" class="float-center" >
</th>
<th class="expander"></th>
</tr>
</table>
</th>
</tr>
</tbody>
</table>
<!-- Row 2 -->
<table class="row collapse bgcolor--blue">
<tbody>
<tr>
<th class="small-12 large-12 columns">
<table>
<tr>
<th>
<img src="http://24.media.tumblr.com/7a40daf7853d830815fb83f79752e94a/tumblr_mz2izkaidT1rfn9zxo4_500.png" alt="Fashion news" align="center" class="float-center">
</th>
<th class="expander"></th>
</tr>
</table>
</th>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</body>
I didn't notice this should happen. Try this CSS :
th {
text-align: center;
}
th a {
display: inline-block;
}
edit using #SpencerMay comment
Basically, because of the layout of my website ( I'm using IP.Content with my IP.Board forum ) I can't really have a single table here. Well, I probably could, but I don't understand how, so I might be asking the wrong question.
Anyway, here's my code:
<div class="box" style="width: 81%; float: right;">
<div class="ipsSideBlock clearfix __xXtop20520players">
<h3 id="anonymous_element_8">
<table style="width:100%;">
<tr>
<th style='text-align: center;'> Icon </th>
<th style='text-align: center;'> Item Name </th>
<th style='text-align: center;'> Description </th>
<th style='text-align: center;'> Price </th>
<th style='text-align: center;'> Controls </th>
</tr>
</h3>
</table>
<div class="_sbcollapsable">
<ul class="shoplist">
<li class="clearfix">
<div class="list_content">
<table>
<tr>
<td> <img src="http://placehold.it/50x50.png" width="50px" height="50px"/> </td>
<td> Item </td>
<td> This is a test description </td>
<td> $29.99 </td>
<td> Button. </td>
</tr>
</table>
</div>
</li>
</ul>
</div>
</div>
</div>
As you can see I have the Table header and the Table data in different sections, this is because of the sheer amount of styling that comes with IP.Board. I'm not very experienced with any of this, but this looks exactly how I want it to.
The only problem is that the table data doesn't stretch the table-headers sizes accordingly with the data. When I look at it, it makes sense as to why. I attempted to leave the table open, but that just made everything show up in the h3 element.
I want to display an image in a table in the center of a cell, but this is what i get. My image covers the complete cell rather than being placed in the center of the cell . I am using an img-responsive class for image and table-responsive for table both from the bootstrap file.
Further, whenever I load the page, i get one of the following outputs randomly with absolutely no change in the code.
Why does this happen??
In both the cases image, image will be seemed to be positioned to the left side of the column, how do I correct it so that image is positioned in the center.
Following is the code
<div class="table-responsive inside_content ps-container" style="margin-bottom: 50px">
<style>
th,td{
text-align: center;
}
</style>
<table id="event" class="table table-striped table-responsive">
<thead>
<tr>
<th>Serial No.</th>
<th>Section</th>
<th>TimeStamp</th>
<th>Archive_Status</th>
<th>Event Picture</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td>
test1 </td>
<td>
Event3 </td>
<td>
2015-01-08 19:41:45 </td>
<td>
0 </td>
<td>
<a class="event_group1" href="http://localhost/IOCLALL/IOCLbackend/../IOCLfrontend/images/events/WWW.YTS_.RE_.jpg">
<img alt="No Image" class="img-responsive" style="max-width:145;max-height: 208px" src="http://localhost/IOCLALL/IOCLbackend/../IOCLfrontend/images/events/WWW.YTS_.RE_.jpg" />
</a>
</td>
<td>
<span class="fa fa-fw fa-trash" ></span>
<span class="fa fa-fw fa-edit" ></span>
</td>
</tr>
</tbody>
</table>
</div>
You must treat the TD like you would treat a P,
add a text-align:center to the TD and a display:inline-block to the image
<td style="text-align: center;">
<img style="display: inline-block;" />
</td>
<td style="text-align: center;">
add css to that td to align text in the center, it should apply for the image as well
Add align="center" to the cell .
Eg.
<td align="center">
<img src="...
how about adding
display:inline / inline-block;
margin:0px auto;
I hope it will answer your question