I have this code on my webpage and I made it with Bootstrap.
<div class="row">
<div class="col-md-11">
Here I have content
</div>
<div class="col-md-1">
Here I have content
</div>
</div>
and I need for this column, that first column to be smaller, 10.5 size and second column to be bigger, 1.5 size. Can I do with width in CSS? Can you help me with this?
Thanks
Bootstrap has no direct provision for partial columns.
You can rewrite the stylesheet to operate on a different number of columns (i.e. 24).
The customize page will let you specify a different number of columns and generate the stylesheet for you.
Alternatively, you can check out Bootstrap from Git and modify the variables file to the same effect.
Just create your own break points:
#media (min-width: 992px) {
col-md-10-5 {
width: 9.523809523809524%; // 100 / 10.5
}
col-md-1-5 {
width: 66.666666666%; // 100 / 1.5
}
}
Alternative You can increase grid size to 24 columns instead of 12 using Bootstrap generator.
Bootstrap provide you with general purpose components. I believe bootstrap rows and columns are generally designed to contain different website parts or different functionality (e.g. right column with most recent news feed and the main body with current article)
I guess you are trying to build your own component/markup that should not be splitted by bootstraps rows and cols. I suggest to write your own css for it.
<div> <!--some container (e.g. bootstrap container or column)-->
<div class="my-component">
<div class="main-part"></div>
<div class="additional-part"></div>
</div>
</div>
.my-component {
/*something*/
}
.my-component > .main-part {
width: 600px;
/*some margin or padding*/
}
.my-component > .additional-part {
width: 200px;
/*some margin or padding*/
}
And include media queries if necessary.
I advise not to override framework grid system.
Since col-md-1 is of width 8.33333333%;
<div class="col-md-1" style="width: width: 12.499999995%;
flex: 0 0 12.499%;max-width: 12.499%;"> # 8.33333333 * 1.5
Here I have content
</div>
And for the col-md-11, you'd have to adjust it to be 10.5:
<div class="col-md-10" style=" width: 87.499999965%;flex: 0 0 87.499999965%;max-width: 87.499999965%;"> # 8.33333333 * 10.5
Here I have content
</div>
Related
I am trying to make a collapsible grid on bootstrap to show details of each item:
Here is a link to a picture to show the main idea.
I have been following the following thread which has been very useful: https://www.codeply.com/go/TLJi5MxQ1E
However they way that their html is coded, each row on small screen must be a factor of each row on a large screen (eg. 4 rows on screen --> 2 rows on a small screen)
What I am trying to do is to have 3 increments: 3 columns, 2 columns, and 1 column and I am unable to figure out how to make it work. Any help will be appreciated
a few things:
You should add what you have tried to accomplish this instead of just coming here for someone to write code for you.
With that said, I used to do the same thing occasionally in my earlier questions, so i have decided to help you.
here is the solution for desktop (without bootstrap) keep in mind bootstrap is dynamic and will adjust your content to screen size on tablet, desktop or mobile.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
#container {
display: flex;
flex-direction: column;
border: 2px solid grey;
}
.row {
display: flex;
align-content: center;
justify-content: center;
}
img {
height: 200px;
width: 200px;
border: 1px solid black;
}
</style>
</head>
<body>
<div id="container">
<div class="row">
<img src="https://lh3.googleusercontent.com/proxy/fEYdsyPpuHjBaYcf-ImCa4jrGrKo3qIHzfgEvoYHMPQaqrxuPXHzDFxhL15qpYPOYp-8R0ELgc0JZ0LCJaLgDghVBu3a_TTAOB2cPu5tdt_Kb03WFEflMWse2H9KGPJ1aMRCoARvdofMWBFnVhavJw">
<img src="https://lh3.googleusercontent.com/proxy/fEYdsyPpuHjBaYcf-ImCa4jrGrKo3qIHzfgEvoYHMPQaqrxuPXHzDFxhL15qpYPOYp-8R0ELgc0JZ0LCJaLgDghVBu3a_TTAOB2cPu5tdt_Kb03WFEflMWse2H9KGPJ1aMRCoARvdofMWBFnVhavJw">
<img src="https://lh3.googleusercontent.com/proxy/fEYdsyPpuHjBaYcf-ImCa4jrGrKo3qIHzfgEvoYHMPQaqrxuPXHzDFxhL15qpYPOYp-8R0ELgc0JZ0LCJaLgDghVBu3a_TTAOB2cPu5tdt_Kb03WFEflMWse2H9KGPJ1aMRCoARvdofMWBFnVhavJw">
</div>
<div class="row">
<img src="https://lh3.googleusercontent.com/proxy/fEYdsyPpuHjBaYcf-ImCa4jrGrKo3qIHzfgEvoYHMPQaqrxuPXHzDFxhL15qpYPOYp-8R0ELgc0JZ0LCJaLgDghVBu3a_TTAOB2cPu5tdt_Kb03WFEflMWse2H9KGPJ1aMRCoARvdofMWBFnVhavJw">
<img src="https://lh3.googleusercontent.com/proxy/fEYdsyPpuHjBaYcf-ImCa4jrGrKo3qIHzfgEvoYHMPQaqrxuPXHzDFxhL15qpYPOYp-8R0ELgc0JZ0LCJaLgDghVBu3a_TTAOB2cPu5tdt_Kb03WFEflMWse2H9KGPJ1aMRCoARvdofMWBFnVhavJw">
</div>
<div class="row">
<img src="https://lh3.googleusercontent.com/proxy/fEYdsyPpuHjBaYcf-ImCa4jrGrKo3qIHzfgEvoYHMPQaqrxuPXHzDFxhL15qpYPOYp-8R0ELgc0JZ0LCJaLgDghVBu3a_TTAOB2cPu5tdt_Kb03WFEflMWse2H9KGPJ1aMRCoARvdofMWBFnVhavJw">
</div>
</div>
</body>
</html>
if you want to customize this further, you will need to familiarize yourself with media queries in CSS. you can write rules for displaying 2 per row, or 4 per row, or whatever per row, based on your own logic.
with the code here and some research on media queries, you will be able to accomplish this.
IF...you update your question with some code, and what you have tried (i have given you code and pointed you in the right direction) I will be happy to comment or help.
Cheers
Media query width is not applying to col-md class. Below is my code. I am using latest version of Bootstrap.
<div class = "col-md-8 article-container-fix">
<div class = "articles" >
<article class="clearfix">
<header>
line 1
line 2
line 3
</header>
</article>
</div>
</div>
CSS code
#media(max-width: 1199px){
.article-container-fix {
width: 400px;
margin-left: 1em;
background: black;
color: white;
}
}
Except width, all three other properties apply to this class ".article-container-fix" but not that "width: 400px". I don't know where I am missing anything.
I would suggest you to try it with a bit less max-width than 1199, something like 720px to see if it works or not. Other way to output this would be the following
HTML:
<div class="col-md-8">
<div class="article-container-fix">
Content here!
</div>
</div>
And use the same CSS you used before. It's complicated with bootstrap to actually get some things in place the way you want it, and for this, it could be interfering with pretty much anything. Hopefully this will work for you.
ITS Due to you have write your article-container-fix class with col-md-8 class. col-md-8 is a Bootstrap framework class. By default there is a default width given in bootstrap.css.
There is two way to overcome from this problem:
Either you have to write !important in your media query like width: 400px !important;
Or
You have to re-positioning your css in your <head> tag, include most last your responsive.css in your <head> tag.
I am currently working on a responsive framework which contains a section that has max. 3 columns when the browser is not scaled. I use Pseudo selectors (nth) with these column to change the height of the odd divs. The responsiveness works like a charm, no problem there. The odd/even divs work fine, it behaves perfectly even when scaled down.
My problem is this:
I made a listview with divs because the intention was to make the even and the odd divs fit one below the other and next to each other seamlessly with negative top margins. That does not seem to work unfortunately. there are gaps that I can't seem to get rid of.
A mockup to clarify my intentions:
Example
I would like to have a full css solution for getting rid of the gaps but i'm afraid that's not possible unless there's something i'm totally missing.
Html:
<section class="home">
<p>It's <span id="demo"></span> today</p>
<div class="work">
<div class="work_col-1-3">test1</div>
<div class="work_col-1-3">test2</div>
<div class="work_col-1-3">test3</div>
<div class="work_col-1-3">test4</div>
<div class="work_col-1-3">test5</div>
<div class="work_col-1-3">test6</div>
<div class="work_col-1-3">test7</div>
<div class="work_col-1-3">test8</div>
<div class="work_col-1-3">test9</div>
<div class="work_col-1-3">test10</div>
<div class="work_col-1-3">test11</div>
<div class="work_col-1-3">test12</div>
</div>
</section>
CSS
#media only screen and (min-width: 35em) {
.work_col-1-3 {
position:relative;
width: 33%;
height: 200px;
background-color:purple;
display:inline-block;
margin:-2px;
}
.work_col-1-3:nth-child(odd) {
position:relative;
background-color:orange;
margin:-2px;
height:300px;
}
Also here's a fiddle. The fiddle contains just the 3 column part of the css but it should fit in every state. ( 3-column, 2-column & 1-column but the 1 column is working already)
http://jsfiddle.net/Vishumahabir/tB7Aw/
The "section" element is a child object in an "article" element.
Any thoughts? Thank you!
If the heights are set then you can use the following to do it, though it's very ugly especially if you add more elements
.tmcwork_col-1-3:nth-child(2n + 5), /* Select oranges after first line */
.tmcwork_col-1-3:nth-child(2n + 8) { /* Select purples after second line */
top:-100px;
}
.tmcwork_col-1-3:nth-child(2n + 11) { /* Select oranges after third line */
top:-200px;
}
Demo
If the heights vary or you have a lot more elements it'd be easier to look at an existing one and use a similar technique as them
I have a page I am setting up so that it looks the image below on the widest resolution, however on smaller resolutions the page setup will change what images are being displayed on screen, so I wanted to use a media query and data attribute. Only problem is:
I am not sure if I am using the data attribute correctly, and
I have no idea how I would target the <p> tags with a selector so I can use :after to display the image of the badges after the text.
This cant use any jquery/jscript as a requirement so it's kind of a pain.
Demo, it should be configured properly with bootstrap. (The image is linked correctly, but not being displayed due to the attr.)
Sample HTML:
<div id="main" class=" container">
<div class="row">
<div class ="col-lg-6 " id="badgeBox">
<div class ="col-lg-12" data-test="<a href='http://www.va.gov/' target='_blank'><div class='badgeContainer'><img id='va_badge' class =' badges img-responsive' src='http://i.imgur.com/BAbUq6v.jpg'alt='Veteran Affairs Badge'></a></div>"> </div>
<span><p> U.S. Department of Veteran's Affairs</p></span>
</div>
</div>
</div>
Sample CSS:
.badgeContainer {
width: 30%;
}
#media screen and (min-width: 1200px) {
//some selector that targets the p tag// :after {
content:"("attr(data-test) ")";
}
}
I think setting content from a data attribute would work like this.. However, the data-test needs to be inside the p and you'll have the larger problem of encoding the HTML content inside data-test..
#media screen and (min-width: 1200px) {
p:after {
content: attr(data-test);
}
}
A more Bootstrap friendly approach would be to use the included utility classes (http://getbootstrap.com/css/#responsive-utilities) to only show the image link at larger resolutions use visible-lg.
Here's a demo with both approaches: http://bootply.com/94916
For a web application I'm creating (in Umbraco, but don't think that really matters in this case) I need a page that can show an overview of different media types; audio, video and images.
No problem there, for images and videos (hosted on YouTube) I will show a thumbnail and for audio I will show a static image.
The rough layout of an item will be that the image is shown on top, and below that is some info like the title and a short description.
Now because of the difference in dimensions of the images (thumbnails can have a variable size, the audio static image will probably always be smaller than the thumbnails, etc.) one item (or column if you will) can be of less width than another.
What I would like to do is show three items per row, and when the row isn't completely filled I would like to fill it up with a colored box. But that box should not always be at the end, it could also be in between, or the beginning. It just is inserted 'randomly' when a space fill is needed.
Because a picture says more than 1000 words (wire-frame of what I'm trying to describe);
Now my question; is this at all possible? If yes, how?
I can't wrap my mind around it, it can't be done in pure HTML and CSS I think. Because you couldn't determine how big an item is and if a 'filler' is needed.
The rough HTML I have right now is something like this:
<table id="portfolio">
<tr>
<td>
<div class="portfolioItem">
<div class="portfolioItemImage">
<a rel="prettyPhoto" href="http://www.youtube.com/watch?v={video}"><img src="http://img.youtube.com/vi/{video}/1.jpg"/></a>
</div>
<br clear="both" />
<div class="portfolioItemDescription">
<h3>Title</h3>
<p>Description lorem ipsum etc.</p>
</div>
</div>
</td>
</tr>
</table>
Of course there is some more dynamic stuff in there to determine whether it is a video, audio or image, determine when to start a new row, etc. but that isn't relevant here.
Here is the CSS associated with it:
#portfolio {
width:100%;
}
#portfolio td {
width:33%;
}
#portfolio .portfolioItem {
border: 1px solid #000;
}
#portfolio .portfolioItem .portfolioItemImage {
margin:0px;
padding:0px;
}
Again; can this be done? And how?
Thank you!
I think that what you want is jQuery Masonry or the Wookmark jQuery Plugin.
I would create the grid using DIVs instead of TABLES, regardless I think this is what you are looking for?:
#portfolio td
{
min-width:33%;
}
EDIT:
Here is a rudimentary example of a grid created with DIV's:
http://jsfiddle.net/rdtnU/
<div class="con">
<div class="row">
<div class="cell">a</div>
<div class="cell">b</div>
<div class="cell is_last">c</div>
</div>
<div class="row">
<div class="cell">d</div>
<div class="cell">e</div>
<div class="cell is_last">f</div>
</div>
</div>
.con {}
.row { width:340px; margin:0 0 20px 0; overflow:hidden; }
.cell { width:100px; margin:0 20px 0 0; float:left; background:orange; }
.is_last { margin:0; }
I would use the div's as suggested but I would not limit myself to the row/columns as stated. I would use a more fluid layout even if it is for a specified width of a certain section.
The following will only work if you know the width of the div with the content, to allow the floating to occur (this could work if there is a min-width or if your code can determine the size of the image)
Here is the HTML
<div class="elements">
<div class="singleElement">
text and graphics here.
</div>
<div class="singleElement">
text and graphics here.
</div>
<div class="singleElement">
text and graphics here.
</div>
<div class="singleElement">
thisonewillpushthewidthoftheboxfartherthanthe150pxwidth
</div>
<div class="singleElement">
small text
</div>
</div>
Here is the CSS (I put some simple background colors so you can see what is going on with the width and how things are tucked in where space is available.
.elements { overflow: hidden; width: 500px; background: #FCC; }
.singleElement { padding: 5px; white-space:nowrap; float: left;
height: 200px; min-width: 100px; background: #CCC;margin: 0 10px 10px 0; }
Please note the details of the styles are just for demonstrating the example. They can be altered to fit your need.
EXAMPLE: Here is the example in jsFiddle.