This question already has answers here:
How to center content in a Bootstrap column?
(11 answers)
Closed 20 days ago.
I have been trying to center the content of my div that contains the tags "h1, p & table". Due to the table the styling of my page wont allow me to center the second divs contents. It is something I have trialed and tested but to no avail. Would anyone be able to help me out?
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<div class="container-fluid" style="background-color: rgba(0, 0, 0, 0.8); color: white;">
<div class="row">
<div class="col-md-12" style="padding-left:0; padding-right:0;">
<img src="images/Charlie-Co.-Barbershop-West-Chester-3.png" class="img" width="100">
<a
href="https://booksy.com/en-ie/3715_charlies-barbers-lucan_barbers_52867_ireland"
class="carousel-caption">Book now!</a>
</div>
</div>
<div class="row">
<div
class="col-md-9 border-right border-bottom border-dark"
style="padding-left: 0; padding-right: 0;" id="OpenTime">
<div class="row">
<div class="col-md-6">
<h1 style="font-family: Playfair Display;">Test Barbershop</h1>
<p style="font-family: Quicksand;text-align: justify;">
<br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non ultricies velit, eget suscipit velit. Nam laoreet magna ornare ex ornare ultrices. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean vel tincidunt velit. Nam sed est metus. Maecenas commodo dolor non lorem semper malesuada. Aliquam tempor blandit sapien in sodales. Integer eu metus efficitur ligula mattis pretium. Donec finibus mi non sodales condimentum. Donec elementum nunc quis mauris pulvinar porta. Sed sed est eget justo vestibulum malesuada vitae at nulla. Suspendisse quis efficitur lorem. Phasellus non ornare ante. Mauris ullamcorper, ligula in malesuada malesuada, purus nibh pretium dui, ac eleifend purus mauris vel nisi. Sed lacinia hendrerit magna at pharetra. Suspendisse quis varius diam, et ultricies dui. In scelerisque felis ac sapien bibendum, eget iaculis nisl egestas. Proin tempor et magna eu molestie. Praesent consequat lorem ut accumsan vehicula. Nunc luctus turpis non sollicitudin fermentum. Fusce nec viverra ex, sit amet tristique turpis.รน
</p>
</div>
<div class="col-md-6" id="OpenTime">
<h1 style="font-family: Playfair Display;">Opening hours</h1>
<p style="font-family: Quicksand;">
<br>
Hours could change depending on Holidays & Bank Holidays
</p>
<table>
<tr class="monday fvl-d">
<td><span>Monday</span></td>
<td>9:30 - 18:30</td>
</tr>
<tr class="tuesday fvl-d">
<td><span>Tuesday</span></td>
<td>9:30 - 18:30</td>
</tr>
<tr class="wednesday fvl-d">
<td><span>Wednesday</span></td>
<td>9:30 - 18:30</td>
</tr>
<tr class="thursday fvl-d">
<td><span>Thursday</span></td>
<td>9:30 - 19:00</td>
</tr>
<tr class="friday fvl-d">
<td><span>Friday</span></td>
<td>9:30 - 19:00</td>
</tr>
<tr class="saturday fvl-d">
<td><span>Saturday</span></td>
<td>9:00 - 18:00</td>
</tr>
<tr class="sunday fvl-d">
<td><span>Sunday</span></td>
<td>11:00 - 15:30</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
Thanks in advance to anyone who might have any suggestions!
you have a fluid container, so just add justify-content-center to the row to actualy center its childs.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid" style="background-color: rgba(0, 0, 0, 0.8); color: white;">
<div class="row">
<div class="col-md-12" style="padding-left:0; padding-right:0;">
<img src="images/Charlie-Co.-Barbershop-West-Chester-3.png" class="img" width="100">
Book now!</div>
</div>
<!-- here is the class added -->
<div class="row justify-content-center">
<div class="col-md-9 border-right border-bottom border-dark" style="padding-left: 0; padding-right: 0;" id="OpenTime">
<div class="row">
<div class="col-md-6">
<h1
style="font-family: Playfair Display;">
Test Barbershop</h1>
<p
style="font-family: Quicksand;
text-align: justify;">
<br>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non ultricies velit, eget suscipit velit. Nam laoreet magna ornare ex ornare ultrices. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean vel tincidunt velit. Nam sed est metus. Maecenas commodo dolor non lorem semper malesuada. Aliquam tempor blandit sapien in sodales. Integer eu metus efficitur ligula mattis pretium. Donec finibus mi non sodales condimentum. Donec elementum nunc quis mauris pulvinar porta. Sed sed est eget justo vestibulum malesuada vitae at nulla. Suspendisse quis efficitur lorem. Phasellus non ornare ante. Mauris ullamcorper, ligula in malesuada malesuada, purus nibh pretium dui, ac eleifend purus mauris vel nisi. Sed lacinia hendrerit magna at pharetra. Suspendisse quis varius diam, et ultricies dui. In scelerisque felis ac sapien bibendum, eget iaculis nisl egestas. Proin tempor et magna eu molestie. Praesent consequat lorem ut accumsan vehicula. Nunc luctus turpis non sollicitudin fermentum. Fusce nec viverra ex, sit amet tristique turpis.</p>
</div>
<div class="col-md-6" id="OpenTime">
<h1 style="font-family: Playfair Display;">Opening hours</h1>
<p style="font-family: Quicksand;"><br>Hours could change depending on Holidays & Bank Holidays</p>
<table>
<tr class="monday fvl-d">
<td><span>Monday</span></td>
<td>9:30 - 18:30</td>
</tr>
<tr class="tuesday fvl-d">
<td><span>Tuesday</span></td>
<td>9:30 - 18:30</td>
</tr>
<tr class="wednesday fvl-d">
<td><span>Wednesday</span></td>
<td>9:30 - 18:30</td>
</tr>
<tr class="thursday fvl-d">
<td><span>Thursday</span></td>
<td>9:30 - 19:00</td>
</tr>
<tr class="friday fvl-d">
<td><span>Friday</span></td>
<td>9:30 - 19:00</td>
</tr>
<tr class="saturday fvl-d">
<td><span>Saturday</span></td>
<td>9:00 - 18:00</td>
</tr>
<tr class="sunday fvl-d">
<td><span>Sunday</span></td>
<td>11:00 - 15:30</td>
</tr>
</table>
</div>
Related
I'm creating a new layout for my site and I'm starting with tables. Currently I've got a fairly simple code for my tables and you can see it here: (http://www.thelanternlight.com/misc/new01.html)
I'm trying to have NO scrollbars on the entire page but rather ONLY a vertical scrollbar in ONLY the teal cell you see on that page (the one with lowright written in it). That is where my content will be.
The main issue I'm facing is that I don't want to provide dimensions for my table or its cells because I want to use 100% for width and height so that it covers the entire page no matter what browser settings the user has. If at all possible I just want to add an overflow scrollbar to that teal TD cell alone.
I'll also provide the code I have currently:
<table style="width:100%" height="100%" bgcolor="pink" cellspacing=0 cellpadding=0 class="alignment">
<tr>
<td align="left" bgcolor="red" colspan="2" height="150">topleft</td>
<td align="right" bgcolor="yellow">topright</td>
</tr>
<tr>
<td align="left" bgcolor="magenta" width="100">lowleft</td>
<td align="center" bgcolor="blueviolet" width="100">lowcenter</td>
<td align="center" bgcolor="teal">
<div style="overflow-y:scroll; overflow-y:auto; width:100%">lowright
<p>
</div>
</td>
</tr>
</table>
Give that cell a height or it will keep growing as content is added never triggering the scroll:
<table style="width:100%" height="100%" bgcolor="pink" cellspacing=0 cellpadding=0 class="alignment">
<tr>
<td align="left" bgcolor="red" colspan="2" height="150">topleft</td>
<td align="right" bgcolor="yellow">topright</td>
</tr>
<tr>
<td align="left" bgcolor="magenta" width="100">lowleft</td>
<td align="center" bgcolor="blueviolet" width="100">lowcenter</td>
<td align="center" bgcolor="teal"><div style="overflow-y:auto;
height: 100px; width:100%">lowright
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras accumsan eleifend enim, nec vestibulum risus dignissim sit amet. In hac habitasse platea dictumst. Maecenas at enim eu magna laoreet rhoncus. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Phasellus ac pellentesque enim, at pulvinar orci. Phasellus quis vestibulum nunc. Etiam mattis nulla orci. Donec elementum odio lacus, quis tempus ante eleifend sit amet. Nam congue ut dui vitae eleifend.
Nulla convallis consectetur diam vitae pulvinar. Nam varius hendrerit rutrum. Quisque finibus mattis turpis at dignissim. Praesent hendrerit libero lacinia nibh sodales pretium. Etiam in massa lacinia, posuere lectus non, efficitur nisl. Donec ut turpis vel lectus consequat ornare non molestie nulla. Sed at ante id diam laoreet facilisis vitae et nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Nunc pulvinar, enim vitae hendrerit tincidunt, nibh libero egestas velit, mattis volutpat ante purus et nisi. Mauris feugiat, massa aliquet venenatis semper, ante lectus tempor orci, at tristique leo metus id magna. Sed vestibulum blandit orci, non facilisis felis mollis vel. Donec auctor tincidunt hendrerit. Donec sodales mollis consectetur. Nulla eget tristique felis, eget scelerisque massa. Aliquam nisi mi, feugiat eu ligula quis, dictum varius turpis. Praesent sed leo a dolor egestas rutrum vitae nec diam.
</p>
</div>
</td>
</tr>
</table>
<table style="width:100%" height="100%" bgcolor="pink" cellspacing=0 cellpadding=0 class="alignment">
<tr>
<td align="left" bgcolor="red" colspan="2" height="150">topleft</td>
<td align="right" bgcolor="yellow">topright</td>
</tr>
<tr>
<td align="left" bgcolor="magenta" width="100">lowleft</td>
<td align="center" bgcolor="blueviolet" width="100">lowcenter</td>
<td align="center" bgcolor="teal">
<div style="overflow-y:scroll; width:100%">lowright
<p>
</div>
</td>
</tr>
</table>
<div style="overflow-y:scroll; width:100%">lowright
Body overflow-y: hidden;
I put the overflow-y: hidden in the body and overflow-y:scroll in the div
Try it
I am attempting to vertically align my text in the center of its row regardless of how long the text is in my bootstrap table.
I am attempting to handle this with vertical-align: middle; line-height:90px; At the moment adjusting the line-height seems to work and allow me get text in the center but if the text is two-lines then the line-gap between the two is too large.
How can I vertically align my text in the right column to fit vertically be in the middle of the page?
Here is my code snippet :
.table-bordered th, tbody td:nth-child(2) {
vertical-align: middle;
line-height: 90px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<table class="table table-bordered">
<thead class="text-14 tx-light">
<tr class="d-flex">
<th class="col-6 blue-background" scope="col">LEFT</th>
<th class="col-6 red-background" scope="col">RIGHT</th>
</tr>
</thead>
<tbody class="text-18 tx-dark">
<tr class="d-flex">
<td class="col-6" scope="row">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus bibendum placerat sapien, vel consectetur dolor congue id. Duis posuere nisl eget magna posuere malesuada. Nunc ac euismod nulla. Nunc efficitur tincidunt facilisis. Proin sed efficitur velit. Donec non sem sed lorem faucibus finibus. Cras tristique turpis vitae scelerisque fringilla.
</td>
<td class="col-6"> <a class="text-underlined-18 ul-link">Link to the described article here </a></td>
</tr>
<tr class="d-flex">
<td class="col-6" scope="row">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus bibendum placerat sapien, vel consectetur dolor congue id. Duis posuere nisl eget magna posuere malesuada. Nunc ac euismod nulla. Nunc efficitur tincidunt facilisis. Proin sed efficitur velit. Donec non sem sed lorem faucibus finibus. Cras tristique turpis vitae scelerisque fringilla.
</td>
<td class="col-6"> <a class="text-underlined-18 ul-link">Link to longer url that takes up two lines here test test test test </a></td>
</tr>
<tr class="d-flex">
<td class="col-6" scope="row">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus bibendum placerat sapien, vel consectetur dolor congue id. Duis posuere nisl eget magna posuere malesuada. Nunc ac euismod nulla. Nunc efficitur tincidunt facilisis. Proin sed efficitur velit. Donec non sem sed lorem faucibus finibus. Cras tristique turpis vitae scelerisque fringilla.
</td>ib
<td class="col-6"> <a class="text-underlined-18 ul-link"> Link to article here</a></td>
</tr>
</tbody>
</table>
I am expecting my text to sit in the center of the row similar to this photo without the huge line gap if the text is two-lines:
Change the desired table data element to display: flex;, make the flex-direction: column; and justify-content: center;.
.table-bordered th, tbody td:nth-child(2) {
display: flex;
flex-direction: column;
justify-content: center;
line-height: 90px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<table class="table table-bordered">
<thead class="text-14 tx-light">
<tr class="d-flex">
<th class="col-6 blue-background" scope="col">LEFT</th>
<th class="col-6 red-background" scope="col">RIGHT</th>
</tr>
</thead>
<tbody class="text-18 tx-dark">
<tr class="d-flex">
<td class="col-6" scope="row">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus bibendum placerat sapien, vel consectetur dolor congue id. Duis posuere nisl eget magna posuere malesuada. Nunc ac euismod nulla. Nunc efficitur tincidunt facilisis. Proin sed efficitur velit. Donec non sem sed lorem faucibus finibus. Cras tristique turpis vitae scelerisque fringilla.
</td>
<td class="col-6"> <a class="text-underlined-18 ul-ibisworld">Link to the described article here </a></td>
</tr>
<tr class="d-flex">
<td class="col-6" scope="row">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus bibendum placerat sapien, vel consectetur dolor congue id. Duis posuere nisl eget magna posuere malesuada. Nunc ac euismod nulla. Nunc efficitur tincidunt facilisis. Proin sed efficitur velit. Donec non sem sed lorem faucibus finibus. Cras tristique turpis vitae scelerisque fringilla.
</td>
<td class="col-6"> <a class="text-underlined-18 ul-ibisworld">Link to longer url that takes up two lines here test test test test </a></td>
</tr>
<tr class="d-flex">
<td class="col-6" scope="row">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus bibendum placerat sapien, vel consectetur dolor congue id. Duis posuere nisl eget magna posuere malesuada. Nunc ac euismod nulla. Nunc efficitur tincidunt facilisis. Proin sed efficitur velit. Donec non sem sed lorem faucibus finibus. Cras tristique turpis vitae scelerisque fringilla.
</td>
<td class="col-6"> <a class="text-underlined-18 ul-ibisworld"> Link to article here</a></td>
</tr>
</tbody>
</table>
I have a table in a html5. One of the columns is a description column. And since I am using bootstrap class "col-md-2". The description being long goes a lot down. I want to enable a vertical scroll for that particular <td>. I have tried using style="overflow-y: auto;" with td. But, it doesn't seem to work.
HTML File :
<div class="panel-body">
<table ng-if="applicationListAdmin" st-table="applicationTable" class="table table-striped">
<tr>
<th>Application No.</th>
<th>Project Title</th>
<th>Project Description</th>
<!-- <th>DataSet Available</th> -->
<!-- <th>Impact</th> -->
<th>Number of Interns</th>
<th>Expected SkillSet</th>
<th>Software Licenses Needed</th>
<th>Hardware Requirements</th>
<th>Status</th>
<th>Update</th>
</tr>
<tbody>
<tr ng-repeat="application in applicationListAdmin">
<td class="col-md-2">{{application.number}}</td>
<td class="col-md-2">{{application.title}}</td>
<td class="col-md-2" style="overflow-y: auto;">{{application.description}}</td>
<td class="col-md-1">{{application.numberOfInterns}}</td>
<td class="col-md-2">{{application.skillSet}}</td>
<td class="col-md-2">{{application.software}}</td>
<td class="col-md-2">{{application.hardware}}</td>
<td class="col-md-2">{{application.state}}</td>
<td>
<i class="material-icons" ng-click="view(application._id)">receipt</i>
<i class="material-icons" ng-click='edit(application._id)' style="color:red">edit</i>
<i class="material-icons" ng-click="remove(application._id)" style="color:red">delete</i>
</td>
</tr>
</tbody>
</table>
Css values for table:
th,td {
/*border-style: solid;
border-width: 5px;
border-color: #BCBCBC;*/
word-wrap: break-word;
}
table {
table-layout: fixed;
width: 100%;
}
You can't set the height to the table td. but what you can do is put the contents inside a div and place that div inside the td
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
div{
overflow-y:scroll;
height:100px !important;
}
</style>
</head>
<body>
<table>
<tr>
<th>Month</th>
<th>Description</th>
</tr>
<tr>
<td >
March
</td>
<td >
<div>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,
</div>
</td>
</tr>
</table>
</body>
</html>
For scroll to appear, you need to set the height on the element.
Try:
<td class="col-md-2" style="overflow-y: auto;height: 100px;display:block;">random text</td>
Demo: http://jsfiddle.net/lotusgodkk/GCu2D/2165/
so I am trying to get basically just name, date, number down the bottom in its own row of the table although it works on two of the pages I cannot get it working on the homepage even if I copy/paste from the working ones. Was wondering if anyone out there could take a look and let me know whats wrong (knowing my luck its probably something small)
Here is the one not working;
<html>
<head>
<title>Home Page</title>
</head>
<body>
<table border = "1">
<tr valign = "top">
<th colspan = "4"><img src="C:\Users\Liam\Desktop\ICAWEB301A_AssessFiles\Images\Banner.PNG" width="1200" height="200"></th>
</tr>
<tr>
<th>Home</th>
<td rowspan = "3"><img src="C:\Users\Liam\Desktop\ICAWEB301A_AssessFiles\Images\MainPic.PNG" height = "250"></td>
<td rowspan = "3" width = "500">Lorem ipsum dolor sit amet, consectetur adipiscing elit.
In id mi vitae velit tempus ultrices. Proin varius, nibh
dictum facilisis gravida, lacus nunc scelerisque nulla,
eget mollis nunc risus eu odio. Donec quis dolor interdum
odio molestie viverra. Duis dui ante, molestie in rhoncus
eget, tempor ac diam. Donec erat dui, imperdiet ac varius
eget, accumsan vel mi. Aliquam erat volutpat. Donec
condimentum congue tempus.<p>
Fusce aliquet vehicula euismod. Cras eleifend euismod nisl
eu congue. Donec placerat, felis ut feugiat tempor, arcu
lacus sollicitudin urna, vel ultricies mi dolor sit amet
quam. Ut sed justo nulla, id porttitor purus. Maecenas dolor
libero, laoreet pharetra tincidunt vitae, congue ornare erat.
Cras vitae interdum quam. Donec accumsan lectus mattis
neque adipiscing fringilla. Sed aliquam mi non metus
elementum ac elementum lectus pellentesque. Nullam risus
diam, gravida ac ullamcorper vel, placerat vitae lorem.
Cras in libero sit amet metus rhoncus semper iaculis nec
dui. Integer adipiscing auctor lectus vel hendrerit. </td>
<td rowspan = "3"><img src="C:\Users\Liam\Desktop\ICAWEB301A_AssessFiles\Images\latestNews.PNG"></td>
</tr>
<tr>
<th>Services</th>
</tr>
<tr>
<th width = "200">Contact</th>
</tr>
<tr valign = "bottom">
<td colspan = "4">Name: - ....... Number: - ....... Date: Janurary 27, 2015</td>
</tr>
</table>
</body>
</html>
and here is the working one;
<html>
<head>
<title>Services</title>
</head>
<body>
<table border = "1">
<tr valign = "top">
<th colspan = "4"><img src="C:\Users\Liam\Desktop\ICAWEB301A_AssessFiles\Images\Banner.PNG" width="1200" height="200"></th>
</tr>
<tr>
<th>Home</th>
<td rowspan = "3" width = "100"></td>
<td rowspan = "3" width = "700"><strong>SERVICES</strong><br>
<ul>
<li>class aptent taciti sociosqu ad litora</li>
<li>torquent per conubia nostra, per inceptos</li>
<li>himenaeos. Lorem ipsum dolor sit amet</li>
<li>consectetur adipiscing elit. In aliquam</li>
<li>dui quis auctor pharetra, odio risus </li>
<li>sodales mauris, non scelerisque ligula </li>
<li>justo eu ligula. Mauris metus neque</li>
<li>dictum cursus fermentum sit amet</li>
<li>lobortis nec sem. Fusce ante mauris</li>
<li>consequat id feugiat nec, venenatis </li>
<li>Quisque posuere accumsan orci, a faucibus</li>
</ul> </td>
<td rowspan = "3" colspan = "2"></td>
</tr>
<tr>
<th>Services</th>
</tr>
<tr>
<th width = "150">Contact</th>
</tr>
<tr valign = "bottom">
<th colspan = "4">Name: - ....... Number: - ....... Date: Janurary 27, 2015</th>
</tr>
</table>
</body>
</html>
Thanks a lot for the help :/ I just can't seem to understand why two work but the other one does not.
<center>
<tr valign = "bottom">
<th colspan = "4">Name: - ....... Number: - ....... Date: Janurary 27, 2015</th>
</tr>
It worked when I used th. Try putting this...
<tr valign = "bottom">
<th colspan = "4">Name: - ....... Number: - ....... Date: Janurary 27, 2015</th>
</tr>
Put this code as replacement to your footer code that is not working.
You used TD tag instead of TH.
Like the title says, I am having issues with a VERY long string overflowing my page. I tried some overflow techniques, but none seem to work.
I had previously posted this as a Primefaces problem, but have since learned that it is not a Primefaces issue. Anyway, if anybody has any suggestions on how I can fix this, I would appreciate it. I will post my HTML below so you can see what I am talking about.
Thanks for taking the time to read, and have a great day. :-)
<!DOCTYPE html>
<html>
<head>
<title> overflow </title>
<style type="text/css">
#container{
width: 800px;
border: 1px solid #000;
background-color: #efefef;
}
div {
padding: 10px;
}
span.text {
}
</style>
</head>
<body>
<h3> overflow </h3>
<div id="container">
<table border="1">
<tr>
<td>
<span>cell_X</span>
</td>
<td>
<span>cell_Y</span>
</td>
<td>
<span>cell_Z</span>
</td>
<td>
<span class="text">asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf</span>
</td>
<td>
<span> </span>
</td>
</tr>
<tr>
<td>
<span>cell_X</span>
</td>
<td>
<span>cell_Y</span>
</td>
<td>
<span>cell_Z</span>
</td>
<td>
<span class="text">asdf</span>
</td>
<td>
<span> </span>
</td>
</tr>
<tr>
<td>
<span>cell_X</span>
</td>
<td>
<span>cell_Y</span>
</td>
<td>
<span>cell_Z</span>
</td>
<td>
<span class="text">asdf</span>
</td>
<td>
<span> </span>
</td>
</tr>
<tr>
<td>
<span>cell_X</span>
</td>
<td>
<span>cell_Y</span>
</td>
<td>
<span>cell_Z</span>
</td>
<td>
<span class="text">asdf</span>
</td>
<td>
<span> </span>
</td>
</tr>
<tr>
<td>
<span>cell_X</span>
</td>
<td>
<span>cell_Y</span>
</td>
<td>
<span>cell_Z</span>
</td>
<td>
<span class="text">asdf</span>
</td>
<td>
<span> </span>
</td>
</tr>
</table>
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed semper justo vel felis blandit ut egestas nisi tincidunt. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nunc in est pulvinar orci pharetra fringilla in eget quam. Maecenas id ipsum eget arcu tempus varius eu sit amet neque. Praesent quis consectetur ligula. Nam bibendum, turpis nec dignissim euismod, arcu libero sodales sapien, ut scelerisque magna risus eu orci. Curabitur sit amet turpis at turpis adipiscing luctus nec id felis. Vestibulum luctus mauris quis ante dignissim rutrum. Fusce fermentum enim quis nisl volutpat consequat. Integer lacinia tempor nisi id aliquet. Praesent vitae semper ipsum. Curabitur mauris est, faucibus eu auctor a, egestas vitae nisi.
</div>
<div>
Donec fringilla laoreet leo, eu aliquet dolor mollis sed. Donec ligula turpis, vestibulum sed faucibus at, venenatis consequat turpis. Integer fringilla, ligula in consequat sodales, odio nunc vulputate nisi, non hendrerit dolor mauris sodales nulla. Nulla mattis iaculis nisi, quis lacinia massa dictum vitae. Fusce quis turpis neque, nec adipiscing tortor. Cras et nisi sem, at viverra lacus. Nam posuere odio non lacus facilisis condimentum. Ut ultricies, arcu eget tempus facilisis, urna dui commodo neque, a posuere libero mi ut nisl. Praesent ut semper lectus. Aenean id mauris nulla. Pellentesque dapibus congue varius. Ut id turpis consequat augue pellentesque egestas. Nunc feugiat bibendum tortor, sit amet fringilla enim viverra in. Mauris sit amet lorem eget enim ultrices euismod id eu velit. Duis eu vestibulum sapien.
</div>
<div>
Vivamus volutpat interdum tortor et luctus. Etiam laoreet congue nunc in congue. Nullam interdum mauris eros. Duis at turpis odio, in interdum odio. Aenean feugiat est at libero hendrerit quis laoreet purus egestas. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum sagittis scelerisque venenatis. Morbi tristique rutrum tortor at lobortis. Suspendisse suscipit purus vel massa laoreet vitae dapibus lorem imperdiet. Mauris consectetur arcu et diam iaculis et cursus leo ultrices. Nunc turpis nunc, interdum ac pretium id, facilisis quis libero.
</div>
<div>
Donec eget velit in nisl posuere porttitor ut at nisl. Phasellus eros tortor, pretium at sollicitudin pellentesque, feugiat a tortor. Integer blandit viverra odio, id iaculis odio fringilla ac. Nulla dignissim fermentum lorem ac scelerisque. Vivamus iaculis augue eu sapien porta convallis. Nam faucibus, diam nec condimentum dapibus, erat arcu vehicula nisi, sed vehicula ante ante convallis ipsum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec quam elit, mattis pretium venenatis nec, vehicula ut tellus. Phasellus commodo pretium purus, non viverra erat auctor sed. Ut dui nisl, pellentesque nec placerat non, sagittis condimentum nunc. Donec varius tincidunt est eu consequat. Etiam ac nulla ut nibh sagittis vulputate. Nullam egestas risus eu nunc tincidunt a ultricies libero posuere. Nulla facilisi. Maecenas sagittis est nec tellus sodales porttitor.
</div>
<div>
Nullam vulputate dui ac velit lobortis pellentesque eu a nisi. Maecenas vitae ligula dui, in imperdiet mi. Mauris commodo nisl eu eros sodales sed tempor leo auctor. Nam ornare varius arcu, at dictum ipsum volutpat nec. Aenean sagittis adipiscing hendrerit. Aenean at quam lacus. Donec malesuada bibendum vestibulum. Suspendisse lobortis pretium neque, vitae tempus felis interdum in. Aliquam sed metus in felis sodales interdum. Praesent malesuada nulla pretium arcu consectetur eu dictum lacus elementum. Ut dictum faucibus hendrerit.
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title> problem </title>
<style type="text/css">
.main
{
width:960px;
margin:0 auto;
overflow: scroll;
}
</style>
</head>
<body>
<h4> problem </h4>
<div class="main">
<table border="1">
<tr>
<td>
<span>cell</span>
</td>
<td>
<span> </span>
</td>
<td>
<span>cell</span>
</td>
<td>
<span class="troubleSpan">asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf</span>
</td>
<td>
<span> </span>
</td>
</tr>
</table>
</div>
</body>
</html>
use the word-wrap:break word css attribute & give it an explicit width:
span .text{
word-wrap:break-word;
width:800px;
}
This property will only apply if the element has a visual rendering, is an inline element with explicit height/width, is absolutely positioned and/or is a block element.