I hope you can help me with this one.
I'm trying to transfer the layout of a PHP/SQL website currently using tables to CSS.
I already have the css working (thanks to Yahoo Grid Builder) but now I need to show it programmatically in my website after I have the info on an array (through $row = dbFetchAssoc($result))
I guess the solution is to use n%m to catch the condition I need but I'm struggling with It.
The css I need to replicate is this one, the two class="yui-g" create a row and each class="yui-u first" and class="yui-u" create a cell in that row, so this code gives you a table with 2 rows and 4 columns. I want to show a new item of my array in each "Item N" (cell).
<div class="yui-g">
<div class="yui-g first">
<div class="yui-u first">Item 1</div>
<div class="yui-u">Item 2</div>
</div>
<div class="yui-g">
<div class="yui-u first">Item 3</div>
<div class="yui-u">Item 4</div>
</div>
</div>
<div class="yui-g">
<div class="yui-g first">
<div class="yui-u first">Item 5</div>
<div class="yui-u">Item 6</div>
</div>
<div class="yui-g">
<div class="yui-u first">Item 7</div>
<div class="yui-u">Item 8</div>
</div>
</div>
Thanks for your help guys!
In general - HTML tables should be used to display tabular data, with CSS used to style those tables.
HTML + CSS should be used for layouts, rather than the old ways of using tables to position content.
Use <table> for tabular data (data that you would store in a table). Everything else should be using HTML with CSS. From the looks of your code you should be using tables.
Related
Hi i need to wrap an array like this [TASK 1, TASK 2, TASK 3].
In HTML i want to display it like that TASK 1, TASK 2... and then with a tooltip the user can see the rest of the tasks.
I need that because i have little space in the col.
The piece of HTML is structured like that
EDIT:
<div class="col-2 border-right-yellow fw-bold">
<div class="row body-cells flex-center">
<div class="col-8">
<div class="row">
<div class="col">{{resource.resourcePlanDTO.cognome}}</div>
<div class="col">{{resource.resourcePlanDTO.nome}}</div>
</div>
</div>
<div class="col-4">
<div class="row">
<div class="col">
{{getTasks(resource)}}
</div>
</div>
</div>
</div>
</div>
getTasks is the method i use to take the string array from the back-end
I tried to use some flexbox classes but it didn't work :(
Now the array is displayed like you can see in the image in the column No.Task
Anyone can help? :)
I am having an issue with displaying divs correctly.
I am displaying information about 10 books, and I would like to do so by having 3 rows of 3 and one row for the last book. This is what my first row looks like:
desired
This is the problem I am facing: wrong
I have a template that iterates over 10 books that I get from a search result and then the outer template displays 10 templates that belong to each book.
This is my template code for each book card:
<div class="col-sm-4">
<div class="profile-card text-center">
<img class="img-responsive" src="https://images.unsplash.com/photo-1454678904372-2ca94103eca4?crop=entropy&fit=crop&fm=jpg&h=975&ixjsv=2.1.0&ixlib=rb-0.3.5&q=80&w=1925">
<!-- <img class="img-responsive img-border center-block" src="{{imageFormatterOne}}{{getLargeImage LargeImage}}" alt=""> -->
<div class="profile-info">
<img class="profile-pic" src="https://pbs.twimg.com/profile_images/711000557742395396/jzm8hqwW.jpg">
<h2 class="hvr-underline-from-center">{{getTitle ItemAttributes}}<span>{{getAuthor ItemAttributes}}</span></h2>
<div>Publisher - {{getPublisher ItemAttributes}}<br>
Edition - {{getEdition ItemAttributes}}<br>
ISBN - {{getISBN ItemAttributes}}<br>
Publication Date - {{getPublicationDate ItemAttributes}}<br>
Media- {{getProductGroup ItemAttributes}}<br><br></div>
{{#if isVerifiedUser}}
</div>
</div>
</div>
In the outer template that calls each card template, I have wrapped each card template in a container:
<div class="container">
{{#each getSearchResults}}
{{>searchResult}}
{{/each}}
</div>
I tried doing the negative margin trick, which is why all the cards are attached vertically, but if I remove the code for that, then I face another problem which is that the div changes size to match the amount of text each card has.
To summarize I have two problems:
1) How can I display 3 cards in 3 rows and 1 row with 1 card? Edit: In addition, how could I make this responsive to larger screens? Ex: 4 per row, etc...
2) How can I set every div to a set size so every div is the same size?
Thank you very much.
1) How can I display 3 cards in 3 rows and 1 row with 1 card?
If you are pulling books from an array or list of some kind I would suggest using an loop that displays 3 books per row with an condition that checks if the length variable compared to the current index. If the index is greater less than or equal to the length then the book will be posted if not then it doesn't exit and nothing should be done. This way is you later add a book to the array you will not have to edit the HTML
or if you want it hard coded
use 4 rows
<div class="row">
<div class="col-md-4">book 1</div>
<div class="col-md-4">book 2</div>
<div class="col-md-4">book 3</div>
</div>
<div class="row">
<div class="col-md-4">book 4</div>
<div class="col-md-4">book 5</div>
<div class="col-md-4">book 6</div>
</div>
<div class="row">
<div class="col-md-4">book 7</div>
<div class="col-md-4">book 8</div>
<div class="col-md-4">book 9</div>
</div>
<div class="row">
<div class="col-md-4">book 10</div>
<div class="col-md-8"></div>
</div>
2) How can I set every div to a set size so every div is the same size?
If you want to create a style that ever book should follow
I would suggest Putting an outer around your current template for each book and give that div a class name
<div class="book">
<!-- you template -->
</div>
Now you can style this section uniformly using css
.book {
height: <what you want>;
width: <what you want>;
}
try to separate the 4 divs so each is on its own row:
<code>
div1 id=card1, id=card2, id=card3 />
div2 3 cards />
div3 3 cards />
div4 1 card />
then set style rules.
#card1 {
margin: x x x x;
}
#div1 {
margin-bottom: x x x x;
}
</code>
should work ok!
You can split the array in chunk of 3 and loop trough this chunks creating the div row container and displaying the 3 books in the col-*-4 columns.
I want to know if there is any problem if we do the following using bootstrap 3 with the html structure?
After reading the documentation and some examples all of them recommend doing the following structure
<div class="row">
<div class="col-lg-4" ></div>
<div class="col-lg-4" ></div>
<div class="col-lg-4" ></div>
</div>
but we are using angular in our application and the sizes of each panel could change and also each panel have it's own controller that knows when to expand or not. I already thought about a controller or an state manager but i don't know at the moment the final ui definitions.
So my question is is any problem with the following structure?
<div class="row">
<div>
<div class="col-lg-4" ></div>
</div>
<div>
<div class="col-lg-4" ></div>
</div>
<div>
<div class="col-lg-4" ></div>
</div>
</div>
That structure is fine. However there is a mistake in your class names. It should be 'col-lg-4'.
It may also pay to use some other col-- classes to handle what happens on smaller devices/screen sizes
EDIT:
After re-reading the question I see that they won't have fixed sizes. Perhaps consider implementing a function to assign different sizes to different elements.
E.G.
<div class="row">
<div id="one"></div>
<div id="two"></div>
<div id="three"></div>
</div>
Now you can reference the divs with the different id's and do something like this:
//if you want a large middle column with two smaller columns on the side
$('#one).addClass('col-lg-2');
$('#two').addClass('col-lg-8');
$('#three).addClass('col-lg-2');
note: I'm using jquery for that.
The grid class should be col-lg-4 instead of col-lg 4.
http://getbootstrap.com/examples/grid/
I have the following simplified markup:
<div class="row">
<div class="col-lg-3" ng-if="isSuperUser()">
Conditional column 1
</div>
<div class="col-lg-3">
Column 2
</div>
<div class="col-lg-6">
Column 3
</div>
</div>
I want Column 3 to take up the last 6 grid columns always. I also want the contents of Column 1 or Column 2 if not a super user to take up the first 3 grid columns depending.
The problem is when the Column 1 is not displayed, Column 2 and Column 3 shift to the left such that Column 3 is no longer on the right side. A solution that seems hacky is to add a <div class="col-lg-3" ng-if="!isSuperUser()"> before Column 3, but it seems like there may be a better solution.
I can't see anything in Bootstrap's documentation that demonstrates this functionality. I see there is push and pull classes, but they don't seem to be what I'm looking for.
Thanks in advance.
JSBIN
you can try nest row into the .col-xs-*. That's mean you could use the out row to fixed position before you want hidden something.
<div class="container">
<div class="row">
<div class="col-xs-6">col 6
<div class="row">
<div class="col-xs-2">
2
</div>
<div class="col-xs-10">
10
</div>
</div>
</div>
<div class="col-xs-6">col 6
<div class="row">
<div class="col-xs-12">
your purpose
</div>
</div>
</div>
</div>
</div>
You are looking to offset columns in Bootstrap. Conditionally add the class .col-lg-offset-3 to the second column.
I started to use Twitter bootstrap for this application that I am working on.
I read the documentation about nesting rows in both fixed grid system and in fluid one.
Now, I want to do something like this
So of course I could do something like this
<div class="container">
<div class="row">
<div class="span 12">red</div>
<div class="row">
<div class="span 3">yellow</div>
<div class="span 9">green</div>
</div>
</div>
</div>
and I think I would get what I want. But I am wondering what are the consequences of doing
<div class="container">
<div class="row">
<div class="span 12">red</div>
</div>
<div class="row">
<div class="span 3">yellow</div>
<div class="span 9">green</div>
</div>
</div>
I don't see any difference now in my browser but I am wondering what will happen if I include multiple row elements in single container tag. Is the row-nesting the only proper way to create something like I showed? What is the difference between those two implementations of my design, so to speak?
The second version is more correct. But both work. The difference is how it responds when the page is re-sized. The second version will shrink and react better
However if you want the containers to match the above image you need to use class="container-fluid" and class="row-fluid"
Also remove the spaces between the spans and numbers
class="span 3"
Should say
class="span3"