I'm trying to move the orange plus sign (lower right of screen) up so that it's closer to the other icons, directly below them. Padding-bottom does not work, but padding-top does. I figured the element above it must have a lot of padding that kept it from being able to move up more, but the inspector tool shows there's space between them.
It's hard for me to know what's going on here, as my instructors wrote this code and I don't therefore understand exactly how it's constructed. I'm also quite new to Html/Css, though padding-bottom hasn't failed me thus far.
Here is the partial view code that makes up the second table. The orange plus icon is at the very bottom, underneath the table end tag:
#model IEnumerable<JobPlacementDashboard.Models.JPOutsideNetworking>
}
<table class="table">
<tr>
<th class="sort-button-style table-headers fixed">
<a onclick="sortPartial('#ViewBag.NameSortParm')">Name</a>
</th>
<th class="sort-button-style table-headers fixed">
<a onclick="sortPartial('#ViewBag.PositionSortParm')">Position</a>
</th>
<th class="sort-button-style table-headers fixed ">
<a onclick="sortPartial('#ViewBag.CompanySortParm')">Company</a>
</th>
<th class="sort-button-style table-headers fixed">
<label class="network-label networkingheader">LinkedIn</label>
</th>
<th class="sort-button-style table-headers fixed">
<a onclick="sortPartial('#ViewBag.LocationSortParm')">Location</a>
</th>
<th class="sort-button-style table-headers fixed">
<label class="network-label networkingheader">Email</label>
</th>
<th class="sort-button-style table-headers fixed">
<a onclick="sortPartial('#ViewBag.StackSortParm')">Stack</a>
</th>
<th></th>
</tr>
#foreach (var item in Model)
{
<tr class="text-center">
<td>
#Html.DisplayFor(modelItem => item.Name)
</td>
<td>
#Html.DisplayFor(modelItem => item.Position)
</td>
<td>
#Html.DisplayFor(modelItem => item.Company)
</td>
<td>
LinkedIn
</td>
<td>
#Html.DisplayFor(modelItem => item.Location)
</td>
<td>
#Html.DisplayFor(modelItem => item.Contact)
</td>
<td>
#Html.DisplayFor(modelItem => item.Stack)
</td>
<td class="font20">
#if (User.IsInRole("Admin"))
{
#Html.ActionLink(HttpUtility.HtmlDecode("✎"), "Edit", new { id = item.OutsideNetworkingID })
<span>|</span>
#Html.ActionLink(HttpUtility.HtmlDecode("🗑"), "Delete", new { id = item.OutsideNetworkingID })
}
</td>
</tr>
}
</table>
#if (User.IsInRole("Admin"))
{
<div class="createnewplus">
#Html.ActionLink(HttpUtility.HtmlDecode("+"), "Create")
</div>
}
Here is the part of the Css that targets the plus:
.createnewplus {
font-size:30px;
font-weight:800;
margin-left:1075px;
}
The margin-left is because it automatically displays on the far left, under student name, when it needs to be under the other icons.
If anyone has an idea as to why padding-bottom doesn't work in this case, I'd be very appreciative. I apologize if this is a painfully dumb question; and if you would need more details to be able to tell what's going on, please let me know!
Edit: padding-bottom is not in the css currently because I took it out, as it was doing nothing.
Padding-bottom will create space (padding) below the createnewplus div, therefore moving any content that comes after it farther down the page. It appears that the createnewplus div is the last element on the page, so that is why nothing is changing when you add padding-bottom.
You need to find the css that is responsible for the padding/margin following each table. Lowering it will move your icon up.
Related
When I am using
.right-align {
text-align: right !important;
transform: translateX(-40%);
}
The Table structure is showing below
<table>
<thead>
<tr>
<th>Bid
</th>
<th>Offer
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="right-align">
200
</div>
</td>
<td>
<div class="right-align">
221
</div>
</td>
</tr>
</tbody>
</table>
The td is overlapping the th element as seen below
How can I can make it go under the header ?
This is happening when table is scrolling
It is very hard to answer the question as it is, however, the table should keep its proportions and structure as long as you keep the code tight:
.right-align {
text-align: right !important;
}
<table>
<thead>
<tr>
<th>Bid</th>
<th>Offer</th>
</tr>
</thead>
<tbody>
<tr>
<td class="right-align">200</td>
<td class="right-align">221</td>
</tr>
</tbody>
</table>
It is nebulous why you decided to use the transform: translateX(-40%); rule in there, but it seems you may be trying to overwrite some rules that come from a theme hence the problem you are facing; If you update your question and add more pieces of code or at least what you are trying to achieve then i could be more helpful :). Also if you are using a framework or theme specify which one.
EDIT.
I saw your updates, you don't need to add a div within the td element to apply a class, you can do it directly in the td element. However, it seems that some css rules are overlapping. Maybe a screenshot of the results in a browser could be helpful.
There are several questions on SE about this issue in Bootstrap 3, which have been solved by adding a custom class. Bootstrap 4 includes a text-truncate class to limit the display of text inside an element. We've used it in parts of the site without issue.
However, it doesn't work when applied to a table cell. Here's what we tried - in reality, there are multiple columns to the table but I've trimmed it down to one.
<table class="table table-striped table-bordered table-hover table-hover-cursor" id="tblData">
<thead class="thead-light">
<tr>
<th scope="col" data-bind="tableSort: { arr: _data, propName: 'text()'}">Text</th>
</tr>
</thead>
<tbody data-bind="foreach: pagedData">
<tr>
<td data-bind="text: text()" class="text-truncate"></td>
</tr>
</tbody>
</table>
There are various other question about this which suggest you need to put the text inside a span to have it work. But this doesn't work either.
<tr>
<td>
<span data-bind="text: text()" class="text-truncate"></span>
</td>
</tr>
I've also tried moving the class to the td and having it on both the td and the span. None of it works.
Another common suggestion is to add the text class. Although that doesn't seem to be a default class in Bootstrap. This doesn't work either.
<tr>
<td>
<span data-bind="text: text()" class="text text-truncate"></span>
</td>
</tr>
Again, moving or duplicating the class on the td doesn't make any difference. I wasn't sure if a size limitation might be needed so I tried this:
<tr>
<td data-bind="text: text()" class="col-md-2 text-truncate"></td>
</tr>
But still the text is displayed in full with no elipsis.
In all cases I've check the element to make sure it's picking up the text-truncate class and that the styles are being applied, and they are.
This does work:
<tr>
<td data-bind="text: text()" class="text-truncate" style="max-width: 200px"></td>
</tr>
But I'd prefer to stick to Bootstrap classes. What's the correct set of elements and classes to get this to work?
AFAIK there isn't a Bootstrap class that will solve this if the table columns have fluid width. The simplest solution is to use:
.table {
table-layout: fixed;
}
https://www.codeply.com/go/NysJfvWtst
I am currently trying to force all elements inside of a <th> to be on the same line and am having issues doing so. I've reviewed many posts and the common css answer seems to be to use style="white-space:nowrap" on the <th> element.
The code for <thead> is below:
<thead>
<tr>
<th><h5>Some</h5></th>
<th><h5>Thing</h5></th>
<th><h5>Another</h5></th>
<th><h5>Thing2</h5></th>
<th><h5>OneMore</h5></th>
<th style="white-space:nowrap">
<h5>Thing3</h5>
<md-button class="md-icon-button" style="bottom: 4px;margin-left:-3em">
<md-tooltip md-direction="auto" class="multiple-line-tooltip">
Some ToolTip Information Here
</md-tooltip>
<i class="material-icons md-dark">info</i>
</md-button>
</th>
</tr>
</thead>
My issue is that the info icon seems to always display below the "Thing3" h5 element. See picture below:
All help is appreciated.
A h5 is a block level element - this is by design.
Perhaps try an inline element like <b> instead, or use an inline style.
<h5 style="display:inline">
The problem is that <h5> is a block-level element. You should be able to resolve this by simply floating the children of the header cells to the left:
th > * {
float: left;
}
<table>
<thead>
<tr>
<th>
<h5>Some</h5>
</th>
<th>
<h5>Thing</h5>
</th>
<th>
<h5>Another</h5>
</th>
<th>
<h5>Thing2</h5>
</th>
<th>
<h5>OneMore</h5>
</th>
<th>
<h5>Thing3</h5>
<img src="http://placehold.it/50" />
</th>
</tr>
</thead>
</table>
However, the above example replaces the md-button and i with a simple image. If the above doesn't work for you, try replacing float: left with display: inline-block.
Hope this helps! :)
In my HTML table sometimes I have long words in my cells. So I need to break some words if they overflows its area.
This questions shows how to break table cell: Word-wrap in an HTML table
This css style is recommended : style="word-wrap: break-word; table-layout: fixed; width: 100%"
But if I use table-layout:fixed, my columns becomes equal sized. But in my case width is 100% for table and if table is fixed then columns share width equally. But this takes too much height from page.
My fiddle: http://jsfiddle.net/mavent/Y54s9/17/
What I need ?
- My table has 2 columns, I want second column to be as narrow as possible.
- 2nd column's width shouldn't exceed column's name.
- Column names shouldn't be wrapped. < th > names mustn't be wrapped.
- 1st column should be wide. I don't prefer to fixate column width like %60, %70 etc. But if it is a solution I can use fix column width, but responsiveness must be taken into account.
- Table should be responsive. I will use this table in mobile layouts.
- Word must be wrapped strictly if word exceeds the cell width. For example if cell can take max 40 characters and word is 45 characters, word can be breaked whatever 41. character is.
Output should look like this in small and big screens:
Code:
.myclass1 {
white-space: normal;
}
.myclass2 {
word-wrap: break-word;
table-layout: fixed;
}
<table class="table table-striped table-condensed dataTable myclass1" id="mytable">
<thead>
<tr>
<th class="sorting">header1</th>
<th class="sorting">header2</th>
</tr>
</thead>
<tbody>
<tr class="">
<td class="">
<span class="">Some words are generally short and easy to read
<i class="glyphicon glyphicon-share-alt"></i></span>
</td>
<td class="">
<span><button class="btn btn-primary btn-xs">123</button></span>
</td>
</tr>
</tbody>
</table>
<hr><hr>
<table class="table table-striped table-condensed dataTable myclass1" id="mytable">
<thead>
<tr>
<th class="sorting">header1</th>
<th class="sorting">header2</th>
</tr>
</thead>
<tbody>
<tr class="">
<td class="">
<span class="">Some words are generally short and easy to read, butsomewordsareĞĞÜÜveryverylongIŞÖlikeethisssssGAAAAAAAAAAAAAABBBBBBBBBBBBBbbbbbCCC
<i class="glyphicon glyphicon-share-alt"></i></span>
</td>
<td class="">
<span><button class="btn btn-primary btn-xs">123</button></span>
</td>
</tr>
<tr>
<td>
<span>Some words are generally short and easy to read, butsomewordsare veryverylonglikeethisssssGAAAAAAAAAAAAAABBBBBBBBBBBBBbbbbbCCC
<i class="glyphicon glyphicon-share-alt"></i></span>
</td>
<td class="">
<span><button class="btn btn-primary btn-xs">225</button></span>
</td>
</tr>
</tbody>
</table>
<hr><hr>
<table class="table table-striped table-condensed dataTable myclass2" id="mytable">
<thead>
<tr>
<th class="sorting">header1</th>
<th class="sorting">header2</th>
</tr>
</thead>
<tbody>
<tr class="">
<td class="">
<span class="">Some words are generally short and easy to read, butsomewordsareĞĞÜÜveryverylongIŞÖlikeethisssssGAAAAAAAAAAAAAABBBBBBBBBBBBBbbbbbCCC
<i class="glyphicon glyphicon-share-alt"></i></span>
</td>
<td class="">
<span><button class="btn btn-primary btn-xs">123</button></span>
</td>
</tr>
<tr>
<td>
<span>Some words are generally short and easy to read, butsomewordsare veryverylonglikeethisssssGAAAAAAAAAAAAAABBBBBBBBBBBBBbbbbbCCC
<i class="glyphicon glyphicon-share-alt"></i></span>
</td>
<td class="">
<span><button class="btn btn-primary btn-xs">225</button></span>
</td>
</tr>
</tbody>
</table>
It seems that with HTML and CSS, you cannot cause automatic word breaking in table cells without making table columns of fixed width and using table-layout: fixed). And you cannot specify that one column be just as narrow as it needs and the other column take all the rest (when table-layout: fixed is used).
However, there’s a rather simple JavaScript workaround, though for a large table, it might cause inefficiency (and a flash from initial layout to modified layout). You would not set fixed layout initially, or column widths, just a total width of 100%. You would thus let the browser format the table in automatic layout, so that the second column becomes just as wide as it needs to be (assuming there is enough content in the other column, as we can expect here). Then you just get the width of the second column and explicitly set it on the header cell and you set table layout to fixed.
Sample code:
<style>
#mytable {
word-wrap: break-word;
width: 100%;
}
</style>
...
<table id="mytable"
...
<script>
window.onload = function() {
var t = document.getElementById('mytable');
var th2 = t.rows[0].cells[1];
th2.style.width = th2.clientWidth + 'px';
t.style.tableLayout = 'fixed';
}
</script>
P.S. I still think this is an all wrong approach, unless the cell content is some code of very special kind, like a DNA sequence, that can really be broken at any point. For any normal and abnormal text in human languages, hyphenation or other language-specific word division should be applied. For most code expressions, permissible break points should be indicated, if needed, e.g. with the <wbr> tag or with zero-width no-break spaces.
I have an HTML table like:
<div>
<table border="1">
<thead>
<tr class="example">
<th>
<span id="item1">
<span>Value1</span>
<span class="sort-up no-display"> </span>
</span>
</th>
<th>
<span id="item2">
<span>Value2</span>
<span class="sort-up no-display"> </span>
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>Example 1</td>
<td>Example 2</td>
</tr>
<tr>
<td>Example 3</td>
<td>Example 4</td>
</tr>
</tbody>
</table>
</div>
in header, I have an hidden up arrow which appears when at mouseover/mouseout with jquery
<script type="text/javascript">
$(function(){
$(".example th").on("mouseover mouseout", function(){
var $sort_up = $(this).children().find("span").first().next();
$sort_up.toggleClass("no-display");
});
});
</script>
where no-display is display:none css.
The screenshots (before)
And after:
I want that header title to not be moved at mouseover/mouseout event.
How to do that ? Maybe is a CSS trick.
PS: Maybe like:
Thanks for your patience with me that I have no more knowledge in CSS.
I'm not entirely sure why you're using an image to create the arrow, which then leads to the alignment problems; if you use text() to create a textual arrow, the infamous unicode upwards pointing triangle, then the alignment will maintain itself:
$('.example th').on('mouseover mouseout',
function(e){
var evt = e.type,
sort = $(this).find('span:last');
if (evt == 'mouseover'){
sort.text('▲');
}
else if (evt == 'mouseout') {
sort.text('');
}
});
JS Fiddle demo.
Make these changes
<span id="Val">Value2</span>
#Val{position:absolute;} Add top and left as per your need.
Now, it will remanin fixed even when your arrow appears.
Use a CSS property to get it out of the html flow; either position: absolute or float: right.