Alright so this is a simple question, but I have been figuring this out for a while now and I was wondering if theres any simpler to way to convert this div from a column to row, here's the format right now.
Problem
So how do I make it into columns? I got this template online for free so I may be confused a little, I tried out changing the padding size and such but it ruins the whole layout,
.service-list {
padding: 0 0 0 0;
font-size: 14px;
margin-bottom: 40px;
}
.service-list-col1 {
float: left;
width: 60px;
}
.service-list-col3 {
float: left;
width: 60px;
}
.service-list-col4 {
float: left;
width: 60px;
}
.service-list-col1 i {
font-style: normal;
font-size: 38px;
display: block;
color: #222;
font-family: 'FontAwesome';
line-height: 38px;
}
.service-list-col2 {
overflow: hidden;
}
.main-section.alabaster {
background: #fafafa;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section class="main-section" id="service">
<!--main-section-start-->
<div class="container">
<h2>Services</h2>
<h6>Your investment plus our market experience, endless possibilities.</h6>
<div class="row">
<div class="col-lg-4 col-sm-6 wow fadeInLeft delay-05s">
<div class="service-list">
<div class="service-list-col1"><img src="img/iconn.png" alt="" width="39" height="37" /></div>
<div class="service-list-col2">
<h3>Business development & Project Syndication</h3>
<p>Highest and Best Use Study for Properties<br> Syndication of Projects<br> Project Feasibility Studies<br> Jumpstarting a New Business<br> Brand Planning<br> Business Planning</p>
</div>
</div>
<div class="service-list">
<div class="service-list-col3"><img src="img/iconn.png" alt="" width="39" height="37" /></div>
<div class="service-list-col2">
<h3>investors support and management advisory</h3>
<p>Business Opportunity Scanning<br> Investment Planning & Implementation<br> Negotiations with Local Partners<br> Advisory on Business Entry into Philippines<br> Management to Reposition Existing Property.</p>
</div>
</div>
<div class="service-list">
<div class="service-list-col4"><img src="img/iconn.png" alt="" width="39" height="37" /></div>
<div class="service-list-col2">
<h3>strategies in marketing development, marketing, and sales.</h3>
<p>Strategic Market Research and Planning<br> Positioning & Branding Strategies<br> Market Development Strategies<br> Customized Strategic Marketing & Sales<br> Interventions
</p>
</div>
</div>
</div>
<figure class="col-lg-8 col-sm-6 text-right wow fadeInUp delay-02s"> </figure>
</div>
</div>
</section>
<!--main-section-end-->
In such cases, including HTML markup would help to solve your problem, but let's see.
First of all, you do have rows, the picture given has one column and three rows, so I assume you want to turn those rows into columns.
To do that, make sure the container of those columns (the element that nests all .service-list elements) has width: 100%.
Probably you will have to remove width: 60px from your .service-list-col* elements since that is less than their actual width and it is overflowing, so remove it or set it to something bigger.
If this still doesn't work, try to add display: inline-block to your .service-list elements.
Hope this helps.
UPDATE
Ah, now with the HTML markup it makes more sense. Ignore my css suggestions above, with this structure you can use bootstrap's classes to get your result.
First of all, your service-lists wrapper needs to be able to cover the whole page, for this to happen, you have to define that it takes up 12 columns (default bootstrap css splits the used screen width into 12 columns). To do this, remove these classes col-lg-4 col-sm-6 and add col-xs-12. This will tell bootstrap that this element covers the whole screen width in all screens.
Secondly, you need the service-list divs to cover one third of the screen, so for a good responsiveness I would add to them the classes col-lg-4 col-md-6 col-xs-12. This will make them align 3 per row on a large screen, (12/4 = 3), 2 per row on medium screen (12/6 = 2) and one per row on a small and extra small screen (12/12 = 1).
To sum up, here you can see a working fiddle, I didn't do any changes in your CSS, I just made use of bootstrap classes. Note, to actually see the result, you have to stretch the screen to actually see them line up on the demo.
Related
I'm trying to put two images at the same line with Bootstrap, using two different columns. I aligned them, used some background color two see the result, etc.
But, when I change the resolution to see the responsive effect, they not resize by equal! the images haven't the same width, but yes, the same height. Does anyone have a guess?
Here is the HTML:
.coresq {
background-color: #131313;
}
.cordir {
background-color: #AAAAAA;
}
.top-shows {
margin-left: 0;
margin-right: 0;
}
.top-shows [class^="col-"] {
padding-right: 0;
padding-left: 0;
}
<div class="container">
<div class="row top-shows">
<div class="col-xs-4 coresq ">
<img src="img/slogan_part_1.jpg" alt="imagem" class="slogan_l img-responsive"/>
</div>
<div class="col-xs-8 cordir">
<img src="img/slogan_part_2.jpg" alt="imagem" class="slogan_r img-responsive"/>
</div>
</div>
</div>
When the display reduces, the responsive properties don't resize equally. Shouldn't? Aren't they at the same line?
You have two different column sizes.
col-xs-4 and col-xs-8
you need to use same solumn size for both images if you want them to have same width.
col-xs-6 and col-xs-6 would be the sizes you are looking for.
One image is using double cols (xs-8) than the other (xs-4), so when resizing, the smaller column gets eaten.
Try resizing this external JSFIDDLE with equal cols
(Also, make sure the images are equal size as in the fiddle above)
After some research, I have looking about Flex, that can do it, and saw the new version of bootstrap (4, but still in alpha).
I've reading a lot about, and decided to test. It works! Exactly the way I asked before, with little changes on code.
Well, the custom css is the same, but the Bootstrap is 4 (alpha, for testing) and the HTML is here:
<div class="container">
<div class="d-flex flex-row">
<div class="col-xs-4 coresq ">
<img src="img/slogan_part_1.jpg" alt="imagem" class="slogan_l img-fluid"/>
</div>
<div class="col-xs-8 cordir">
<img src="img/slogan_part_2.jpg" alt="imagem" class="slogan_r img-fluid"/>
</div>
</div>
</div>
.
PS: I don't know why, but the code on snippet preview is cutting the last div ending the code. There is a single point on finish.
I am using bootstrap and basic CSS on my app and for some reason the height-auto on a div isn't working. The height is shown as 0 even though there is text in the div. Here's my html:
<div class="container">
<div class="outlined-div">
<h2 class="text-center col-xs-12" style="color: red">Men are not born knowing how to barbecue.</h2>
<div class="col-xs-12 col-sm-6">
<h4>Good luck explaining this to your buddies.</h4>
<h4>All men are capable. Few are properly trained.</h4>
<h4>Instead, we undergo years of trial and error, suffering through snide comments from our buddies and smug looks from our fathers-in-law. This ends now.</h4>
</div>
<div class="col-xs-12 col-sm-6">
<h4>While men don’t ask for directions (see the man code), it’s only right that we share hints, hacks, and other help with our fellow brothers.</h4>
<h4>Give them a leg up in impressing others with our stellar barbecuemanship.</h4>
<h2 style="color: red">Grill on, brothers.</h2>
</div>
</div> <!-- outlined-div -->
</div> <!-- container -->
Here's my css for outlined-div:
.outlined-div {
background-color: white;
border: solid medium red;
border-radius: 5px;
padding-left: 15px;
padding-right: 15px;
height: auto !important;
}
And here's how it's showing up:
If I put in a fixed height (e.g. height: 10px) the red line expands into a box 10px high.
Can anyone see where I'm going wrong here?
Add the class clearfix to your outlined-div
This will clear the floats added by Bootstrap to create the column layout.
To learn more about clearfixes, read this question: What is a clearfix?
I am following my previous question that has two boxes, that have two images (can be vertical or horizontal), the issue is the height of boxes are fixed and when I change the window screen in some screen sizes the images bypass the border of the boxes.
I checked answers of these questions 1 and 2 but did not help much.
DEMO
CSS
.items { */
position: relative;
margin-bottom: 7px;
margin-left: 7px;
margin-right: 0px;
text-align: left;
background-color: red;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
border-bottom-left-radius: 20px;
padding-left: 1%;
height:260px;
}
.col-md-12.col-xs-12.btn>a>img {
float: right;
width: 100px;
height: 50px;
}
.col-md-12.col-xs-12.my-col {
padding-left: 100%;
}
.my-row {
bottom: 0;
padding-right: 0;
position: absolute;
}
.my-row {
bottom: 0;
padding-right: 0;
position: absolute;
}
.btn {
float: right;
bottom:0;
margin-right:-12px;
margin-bottom:-6px;
position:absolute;
right:0;
}
HTML
<div class="container-fluid">
<div class="row">
<div class="col-md-3 items">
<div class="row">
<div class="col-md-12 text-center">
<h4>T1</h4>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
<h5>T2</h5>
</div>
</div>
<div class="row">
<div class="col-md-12 row text-center">
<a
href="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQKWYNnGt8d9G1sf8PE0TpOglpZ2dKnHWAP5FB_spYgelcToong"
title="T1" data-gallery rel="nofollow"> <img
id="imageresource"
src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQKWYNnGt8d9G1sf8PE0TpOglpZ2dKnHWAP5FB_spYgelcToong"
class="img-thumbnail" width="30%" style="margin-left: 30px;" />
</a>
</div>
</div>
<div>
<img src="#" class="btn" />
</div>
</div>
<div class="col-md-3 items">
<div class="row">
<div class="col-md-12 text-center">
<h4>T1</h4>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
<h5>T2</h5>
</div>
</div>
<div class="row">
<div class="col-md-12 row text-center">
<a
href="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQKWYNnGt8d9G1sf8PE0TpOglpZ2dKnHWAP5FB_spYgelcToong"
title="T1" data-gallery rel="nofollow"> <img
id="imageresource"
src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQKWYNnGt8d9G1sf8PE0TpOglpZ2dKnHWAP5FB_spYgelcToong"
class="img-thumbnail" width="25%" style="margin-left: 30px;" />
</a>
</div>
</div>
<div>
<img src="#" class="btn" />
</div>
</div>
</div>
</div>
</div>
First off, the markup is over complicated for what you want and line 15 and 45 are applying bootstrap classes .col-md-12 and .row on the same element which is in incorrect. Bootstrap class .col-xx-nn must be assigned to a child element with a bootstrap class .row.
Getting back on track to what you want. I have simplified the HTML code to get your desired result, I think. Check it out and let me know what isn't right and I will change it and explain why.
https://jsfiddle.net/6y4uf16y/84/
What I did was create a container div around the sale image that uses the CSS flex box. This div will take up any remaining space. Therefore, if you change the height of your .items element. The flexbox container will adapt and the sale image will respond appropriately to the new size. There is no fixed heights here except for the one that was placed on the .items class of 260px which I believe is what you wanted.
The reason for this is that the bootstrap class .img-reponsive needs a height and/or width attribute to be responsive. Therefore, I have set the height and width equal to the flex box container around it. You can change the width value or .img-sale back to 30% if you wish.
Moreover, as a bonus, I have aligned the button to always be in the bottom right corner as I think you wanted it.
If this answer solves your problem, don't forget to mark it as the correct solution.
Cheers
Edit Sorry wrong JSFiddle link, correct link has been added. I also added proof that it is dynamic with multiple rows of text in the h4 and h5 elements.
You have to add class
.col-md-12 >a>img.btn {
float: right;
width: 100px;
height: 50px;
}
because .col-md-12.col-xs-12.btn>a>img is not applying to any of your given HTML div content
Is it a design requirement that the images get wider as the boxes get wider? If so, the only way to keep the images within the boxes is to increase the height of the boxes as you increase the height of the images.
If it's not a requirement that the images scale up, then you can see my solution here: http://jsfiddle.net/6y4uf16y/75/
All I did was remove the explicit widths from your images (the first was width="25%" and the second was width="30%") and instead used CSS to control the scale by limiting the max-height of the images. .items img {max-height:100px;}.
Since you have a fixed height and need to keep the images inside the boxes, you know for a fact that also have a fixed maximum height on the images
I am not sure if you can have line break on T1 & T2, otherwise you can do this
img{
max-height:170px;
width:auto
}
DEMO
i agree with #Bhavin Solanki and may be the one thing i will suggest that try to give the
width: 100px;
height: 50px;
in to percentages Or else you can go with Media queries for the particular image selectors that will help you to manage a lot
Your HTML Bootstrap code isn't totally correct:
You can't nest a .col-md-12 class inside a .col-md-3 class not
in my knowledge at least.
Your .rows classes are not always well positioned within the code
see the fiddle link that i prepared below.
I tried to do my best to understand what you want to achieve with your code i also ordered tags within your code so that your divs fit the window size regardless of its width.
EDIT
Try to define the width of your image with vw unit (width:15vw;) That will keep the image from crossing the containing item.
I illustrated an example for you here :
http://jsfiddle.net/merhzqwg/65/
Hope it helps.
OK this is the thing, your code is not very clean. there are some errors as well
for eg: you have used the id="imageresource" twice. An id can ONLY be used once on a single page. Very Important.
but i will provide a quick fix for this.
by default bootstrap adds max-width: 100%; height: auto; to the class img-thumbnail to override that what i have done is i have added a class to both of the images img-sale.
<img class="img-thumbnail img-sale" id="imageresource" src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQKWYNnGt8d9G1sf8PE0TpOglpZ2dKnHWAP5FB_spYgelcToong" width="30%" style="margin-left: 30px;" />
and added the following css:
.img-sale {
max-height: 170px;
width: auto;
}
http://codepen.io/anon/pen/OVwrpJ?editors=110
http://jsfiddle.net/6y4uf16y/82/
but the rest of the code is not recommended to proceed with.
I'm working on a Bootstrap page for the first time. Used to working in HTML/CSS and all just not bootstrap. I'm having some difficulty with the following:
I created a fluid ( full width ) container that spans 4 columns.
The 1st column contains an image, the 2nd text, the 3rd an image and the 4th text again. The next row of columns is alternating.
I want my columns to have a responsive width and height so that if i adjust the viewport, the colums are always squared and stretching the full page. I just can't seem to get this to work. Tried various things. Setting max width, using percentages, background images, img scr tags that scale to 100% etc. but nothing seems to work.
Can anyone tell me how i can make this happen?
Greatly appreciated. No problem if JS or JQuery is needed to make it work. I got the basics covered so i know how to do that if someone points me in the right direction ( not a JS wizard to figure this one out on my own just yet ).
For example, i provided my HTML markup.
The CSS is pretty basic. Just provided the background images in the ft-img columns and some styling for the fonts. Also, currently all col have a fixed height of 400 pixels but that is abviously not the way to go. :P
<div class="container-fluid main-content">
<div class="row">
<div class="col-md-3 ft-img ft-1">
</div>
<div class="col-md-3 ft-text">
<h1>Heading</h1>
<hr>
<p>Paragraph </p>
</div>
<div class="col-md-3 ft-img ft-2">
</div>
<div class="col-md-3 ft-text">
<h1>Heading</h1>
<hr>
<p>Paragraph </p>
</div>
</div>
<div class="row">
<div class="col-md-3 ft-text">
<h1>Heading</h1>
<hr>
<p>Paragraph </p>
</div>
<div class="col-md-3 ft-img ft-1">
</div>
<div class="col-md-3 ft-text">
<h1>Heading</h1>
<hr>
<p>Paragraph </p>
</div>
<div class="col-md-3 ft-img ft-2">
</div>
</div>
</div>
As asked, here's the CSS. I initially did not provide it since it's just the basics and it's just one of the things i tried. As said above.
.ft-img {
background-size: 100%;
background-position: center center;
height: 400px;
}
.ft-text {
background: url('../img/bg.png');
background-position: 10% 10%;
height: 400px;
color: #fff;
font-family: 'Lato', sans-serif;
padding: 40px;
}
.ft-text h1 {
font-size: 2.5em;
font-weight: bold;
}
.ft-text p {
font-size: 1.2em;
}
.ft-1 {
background: url('../img/ft/ft-1.jpg') no-repeat;
}
.ft-2 {
background: url('../img/ft/ft-2.jpg') no-repeat;
}
If you want to be fluid, you can't specify fixed units (px).
Consider using the vw unit to make your heights relative to their widths to maintain squares.
http://www.w3.org/TR/css3-values/#viewport-relative-lengths
so confused at the moment I am trying to place a social icon below a h3 tag that is in the same bootstrap row however having a nightmare doing it.
I am trying to create this effect:
However I cant seem to get those icons below the phone number element when they are in the same row, they just sit on the same line.
The logo is also in the same row as the phone number element so if I created another row and placed the icons in that row they appear to far down the page.
Here is an example of my code:
HTML
<div class="container hidden-sm hidden-xs">
<div class="row">
<div class="brand col-md-6 col-sm-6"><img src="media/img/logo.png" alt="Driven Car Sales" class="img-rounded logo-custom"></div>
<div class="phone-div col-md-6 col-sm-6">
<h3 class="phone-number"><i class="glyphicon glyphicon-phone"></i> 01429 7654287</h3>
<img src="media/img/facebook-icon.png" alt="Facebook" class="facebook-icon">
</div>
</div>
</div>
CSS
.phone-number {
color: #fff;
margin-top: 20px;
display: inline-block;
font: 600 2em 'Open Sans', sans-serif;
float: right;
}
.facebook-icon {
display: block;
height: 30px;
float: right;
}
/* main logo */
.logo-custom {
height: 75px;
}
#media only screen and (max-width : 1199px) {
.logo-custom {
height: 61px;
}
}
Any tips on what I might be able to do to create this effect?
Thanks, Nick :)
Try this Code:
<div class="container hidden-sm hidden-xs">
<div class="row">
<div class="brand col-md-6 col-sm-6"><img src="media/img/logo.png" alt="Driven Car Sales" class="img-rounded logo-custom"></div>
<div class="phone-div col-md-6 col-sm-6">
<div class="col-md-12 col-sm-12">
<h3 class="phone-number"><i class="glyphicon glyphicon-phone"></i>01429 7654287</h3>
</div>
<div class="col-md-12 col-sm-12">
<img src="media/img/facebook-icon.png" alt="Facebook" class="facebook-icon">
</div>
</div>
</div>
</div>
Hope this may useful
I think you might be just over-complicating things in your own mind. Forget about Bootstrap for a minute, if you wanted to just make a page that has two elements stacked one on top of the other, then you'd make sure to use block elements (which means that they will take up 100% the width of the container they are in by default).
The thing is that your custom css is actually overriding this normal behavior because you are expressly setting the phone number to be display: inline-block; and making both elements use float:right. Just remove those from your css rules and you'll get your desired effect:
.phone-number {
color: #fff;
margin-top: 20px;
font: 600 2em sans-serif;
}
.facebook-icon {
display: block;
height: 30px;
}
If you want the items to align to the right, just add the Bootstrap helper class: text-right to the column div or add text-align: right to your css rules.
EDIT: Just a suggestion
Also, you can streamline your markup. If you want the entire container to be hidden on sm and xs devices, then all you have to have in your col classes is col-md-6. And, if you didn't want your container to be hidden at the xs and sm breakpoints, then all you would need is col-sm-6, because that alone would set the columns to be 50% for ALL viewports that are larger than 767px. Remember, col classes are additive. When you add a col class, it's like saying: "make this column this width from this viewport size and up until I tell you otherwise".