I have a question about the CSS property: Position
As I was creating a page that looks this:
As you can see, there is a table and div next to each other. The following codes shows that how I achieve this:
Code Structure:
<div className="daily-task-view">
<table{...getTableProps()}>
<thead >
{headerGroups.map(headerGroup => (
<tr className="table-header-row"{...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => (
<th {...column.getHeaderProps(column.getSortByToggleProps())} className={
column.isSorted
? column.isSortedDesc
? "sort-desc"
: "sort-asc"
: ""
} ><h5 className="table-header-head"><b>{column.render("Header")}
</b></h5></th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{page.map((row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return <td className="table-content" {...cell.getCellProps()}>{cell.render("Cell")}</td>;
})}
</tr>
);
})}
</tbody>
</table>
<div className="search">
<GlobalFilter filter={globalFilter} setFilter={setGlobalFilter}/>
<Button variant="success" className="button-to-add-dailytask">Add Daily Task</Button>
</div>
</div>
CSS:
.search{
margin-left:200px;
border-radius: 20px;
background-color: white;
width:fit-content;
position: absolute;
top: 10px;
left: 780px;
}
.daily-task-view{
padding-top: 10px;
padding-left: 20px;
position: relative;}
So far, the CSS that I have did presented the view that I want BUT when I Zoom In or Zoom Out, The Search which is the div tag didn't follow the action like moving the same way as the table been moving instead it didn't move and stick at that position that I set.
As I want the table and div be together so that that can act the same way (such as Zoom in/Zoom out)
What can I do, I used Absolute and Relative. Based on my understanding, both need to be together but in my case, it doesn't act that way.
Is my understanding of these 2 properties wrong?
Please Help
In your code now, you have the .search div inside the .daily-task-view one. This might be the issue
Here is an example of how you could achieve what I think you have in mind, by using a wrapper div and giving that display: flex, and then making .daily-task-view + .search separate and not .search inside the other. In my example I have also set widths for the div's, but it could be fit-content as well, or what you prefer.
https://codepen.io/akmalmo/pen/BapeXra
HTML
<div class="wrapper"><div class="daily-task-view">
Table
</div>
<div class="search">
Search
</div>
</div>
CSS
.wrapper{display:flex}
.search{
border-radius: 20px;
width:40%;background:red;
margin-left:20px;}
.daily-task-view{
padding-top: 10px;width:60%;background:blue;}
.daily-task-view, .search{padding:20px;}
Does this help?
Related
I'm a beginner to HTML and CSS. I'm using jquery mobile, and jquery ui to build a page. I have added a select menu and two images as buttons next to it. I have set a border width of 1px to see the layout. As it is seen in the picture below select menu border is extended and covers the images so I can't click on them.
select menu border covers image
This is the html
<div id="container" >
<img src="styles/add_button.png" id="addButton" class="imgButton">
<img src="styles/remove_button.png" id="removeButton" class="imgButton">
<form>
<select name="select-native-1" id="selectMenu">
</select>
</form>
</div>
this is the CSS
.imgButton{
float : right;
margin: 0em .2em;
}
#container{
vertical-align: middle;
margin:0em 1em 1em 1em;
}
#selectMenu{
float: right;
}
What is the problem here?
I find tables to be the easiest way to properly align things. Try this...
<table><tr>
<td><select name="select-native-1" id="selectMenu"> </select></td>
<td><img src="styles/add_button.png" id="addButton" class="imgButton"> </td>
<td><img src="styles/remove_button.png" id="removeButton" class="imgButton"></td>
</tr> </table>
And then add widths to the td elements to give it the look you want.
My controller grabs people from the server:
$scope.people = [person1, person2, person3, person4, person5,...]
My template needs to display three people per line. For example if it was a table:
<table>
<tr>
<td>person1</td><td>person2</td><td>person3</td>
</tr>
<tr>
<td>person4</td><td>person5</td><td>person6</td>
</tr>
</table>
I wasn't sure how to conditionally apply the <tr> when $index % 3 == 0 or what the best practices are. I know how to do this by adding grouping logic to the controller but I thought it would be best to keep design logic out of the controller.
There isn't an existing way to do what you are saying with a table. The easiest way to do what you want is to use divs with fixed widths, so that they will auto-wrap after three.
Here is an example:
HTML
<div ng-app="app">
<div ng-controller="TableCtrl" class="my-table">
<span ng-repeat="person in people" class="person">{{person}}</span>
</div>
</div>
CSS
.my-table{
width: 400px;
height: 400px;
border: 1px solid black;
}
.person{
width: 100px;
display: inline-block;
white-space: nowrap;
border: 1px solid black;
}
JavaScript
var app = angular.module('app',[]);
app.controller('TableCtrl', function($scope){
$scope.people = ['Aaron', 'Abraham', 'Adam', 'Aristotel', 'Aziel', 'Azod', 'Azood'];
});
Working copy: http://jsfiddle.net/ZX43D/
After years of angular experience, It's obvious that the best way to do this is to split the array into chunks in the controller. Each time the original array is modified, update the chunked array.
Here is my current solution (It's O(N^2) so doesn't scale for large lists).
Template:
<div ng-app="myapp">
<div ng-controller="testing">
<div ng-repeat="_ in items">
<span ng-show="($parent.$index % 3 == 0) && ($parent.$index + 3 > $index) && ($parent.$index <= $index)" ng-repeat="item in items">
<span ng-show="1">
{{item}}
</span>
</span>
</div>
</div>
</div>
Controller:
angular.module('myapp', []);
function testing($scope){
$scope.items = ['a', 'b', 'c', 'd','e','f','g'];
}
Result:
a b c
d e f
g
Fiddle:
http://jsfiddle.net/LjX3m/
Conclusion:
I'll probably try use CSS for this as #aaronfrost mentions. (However it may not be possible since some wrapping divs may be required for each chunk).
I am supporting a legacy application.
In the CSS there is the following rule:
.dashboard-panel table {
width: 100%;
}
So basically there are many panels, and for all tables in them the width is set to 100%.
Now the problem: in a dashboard panel I have put a calendar control from an external library (richfaces). This calendar control is using a table for displaying the days. And this width:100% is affecting the calendar table.
Example:
<div class="dashboard-panel">
<div id="content">
<table id="table1"> //this is ok
<tr>
<td>
<table id="richfacesCalendarTable"> //this not ok
</table>
</td>
</tr>
</table>
</div>
</div>
What is the proper solution here?
I don't want to go through every panel in this application and put a separate style there.
Mabye if you add something like that into end of your css:
.dashboard-panel table#richfacesCalendarTable {
width: your_desired_width_px !important;
}
or
.dashboard-panel table#richfacesCalendarTable {
width: auto !important;
display: table !important;
}
Hard to say for sure as this is only a small portion of HTML and CSS code you provided. There can be other elements that affects your result.
I'm attempting to create a complex div structure using CSS.
I want it to be made up of four columns. On the left is just a list of images. On the right is the complex div structure that I can't figure out a way to create. There should be two large vertical boxes containing various details. In-between these vertical boxes are any number of horizontal boxes.
My problem is that I cannot work out how to create this div structure in a way that 'scales', i.e. there could be any number of horizontal boxes between the two vertical boxes.
This is the div structure I was attempting to use:
<div class="result">
<div class="detail_1">
<p>Detail 1</p>
</div>
<div class="details">
<p>Details</p>
</div>
<div class="details">
<p>Details</p>
</div>
<div class="detail_2">
<p>Detail 2</p>
</div>
</div>
Any help would be greatly appreciated!
EDIT: I have fixed this problem by just using tables. Thanks for the replies.
Update 2
Your question is: How to make the price & flight_number div the same height as the parent div (container)..
1) Use the technique described here: http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks
2) update your CSS so that the flight number and the price are vertical aligned in the middle of their div.
I think that mine HTML structure is better then yours because it's more clear and easier to work with.
So based on my HTML structure: The parent container (flight_info) is stretchend as long as the content inside (the table with the rows will be the longest). the div's flight_number and price are also the total height of the parent container thanks of the technique described in step 1 above. The extra CSS (step 2) will align the price and flight number nicely in the middle.
OLD
<ul id="flights">
<li>
<ul class="images">
<li><img src="img1" alt="your image" /></li>
<li><img src="img2" alt="your image 2" /></li>
</ul>
<div class="flight_info" id="flight_EK49">
<div class="flight_number">
EK49
</div>
<table>
<thead>
<th>date</th>
<th>from</th>
<th>to</th>
</thead>
<tbody>
<tr>
<td>1/1/2013</td>
<td>departure airfield</td>
<td>destination airfield</td>
</tr>
...
</tbody>
</table>
<div class="price">
€999,99
</div>
</div>
</li>
// duplicate the above for a new flight..
</ul>
And for the CSS style (you must do the rest on your own because this is just an example. I didn't test any of the code):
<style>
#flights .images {
float: left;
width: 250px;
}
.flight_info {
float: left;
width: 700px;
}
.flight_info .flight_number,
.flight_info .price {
float: left;
width: 150px;
}
.flight_info .price {
float: right;
}
.flight_info table {
float: left;
width: 400px;
}
</style>
I think you will get the idea.
EDIT 1
Changed all the position absolutes to floats because it easier with the li's automatic heights.
I also added the leg images of the flight as well, but as I mentioned, you have to do the rest yourself ;)
I have the following HTML:
<div class="wall" >
<table>
<tr>
<div class="tbr01"><th>Content</th></div>
<div class="tbr02"><th>User</th></div>
<div class="tbr03"><th>Published</th></div>
</tr>
</table>
</div>
How do i adjust the width of the th div.tbr01
This is what i've tried in my css file: but i am doing something wrong?
div.wall table tr div.tbr01 th {
width: 100px;
}
Regards,
Thijs
Your HTML is invalid.
You cannot have a <div> as a child of a <tr> or a parent of <th>.
Browsers will perform error recovery in various different ways and often give you a DOM that isn't like you expect (e.g. by moving all the div elements outside the table).
Get rid of the div elements and apply your styles directly to the table cells.
seems it doesn't like the div... apply the class to the th or use
div.wall table tr th {
width: 300px;
}
OR
<div class="wall" >
<table>
<tr>
<th class="tbr01">Content</th>
<th class="tbr02">User</th>
<th class="tbr03">Published</th>
</tr>
</table>
</div>
div.wall table tr th.tbr01 {
width: 300px;
}