I am absolute newbee and wanna create 2 rows. One with 2 img col-4 size and col-8 size and the other row à 3 x col-4 size.
My problem is that the col-8 img is a little bit bigger (height) then the col-4 img.
How can I fix it? I tried a lot but nothing worked.
Thanks for your help.
[problem
.col-4 {
padding-left: 5px;
padding-right: 5px;
}
.col-8 {
padding-left: 5px;
padding-right: 5px;
}
.x1 {
border: 1px solid black;
}
.x2 {
border: 1px solid black;
}
.x1_pic {
width: 100%;
height: auto;
position: relative;
}
.x2_pic {
width: 100%;
height: auto;
position: relative;
}
.x1_header {
position: absolute;
margin-top: -95%;
text-align: center;
}
.x2_header {
position: absolute;
margin-top: -95%;
text-align: center;
}
<div class="container">
<div class="row">
<div class="col-4">
<div class="x1">
<img class="x1_pic" src="./img/header-background.jpg">
</div>
</div>
<div class="col-8">
<div class="x2">
<img class="x2_pic" src="./img/maschine_2.jpg">
</div>
</div>
</div>
<div class="row">
<div class="col-4">
<div class="x1">
<img class="x1_pic" src="./img/header-background.jpg">
</div>
</div>
<div class="col-4">
<div class="x1">
<img class="x1_pic" src="./img/header-background.jpg">
</div>
</div>
<div class="col-4">
<div class="x1">
<img class="x1_pic" src="./img/header-background.jpg">
</div>
</div>
</div>
</div>
]1
Related
<style>
.container{
background-color: lightgray;
text-align: center;
display: inline-block;
position: relative;
border-radius:5px;
}
.itemField{
margin-top:10px;
}
.item {
margin: 10px;
width: 20em;
vertical-align: top;
display:inline-block;
}
.itemInner {
width: 20em;
height: 5em;
margin: 0 auto;
padding: 0.83333333em;
border-width: 1px;
border-style: solid;
box-sizing: border-box;
text-align: left;
position: relative;
white-space: normal;
}
.itemInnerList{
width:fit-content;
background-color: beige;
}
</style>
<div class="container">
<div class="itemInnerList">
<div class="item">
<div class="itemInner ">
<div class="itemInnerText">
Item name 1
</div>
</div>
</div>
<div class="item">
<div class="itemInner ">
<div class="itemInnerText">
Item name 2
</div>
</div>
</div>
<div class="item">
<div class="itemInner ">
<div class="itemInnerText">
Item name 3
</div>
</div>
</div>
<div class="item">
<div class="itemInner ">
<div class="itemInnerText">
Item name 4
</div>
</div>
</div>
</div>
</div>
how can i make sure "itemInnerList" is just wide enough to wrap inner elements in all cases.
itemInnerList container shows like it's wide is 100% , not covers only inner elements .
i draw the boundry in image which i try to make.
i try to make container width, covers only inner elements in all screen width
enter image description here
I have a list of items with a number and text stacked ontop of each other - I am struggling with trying to vertically align the text next to the number it is sitting along side. I have the number and text just floated left inside a div - possibly I need to take a different approach? See working exmaple here - https://codepen.io/ajmajma/pen/gRpxrQ?editors=1100
My html for the items is structured like so :
<div class="featured-posts wrapper">
<div class="featured-posts--posts row">
<div class="featured-post col-12">
<div class="featured-post--wrapper">
<div class="featured-post--body"><span class="featured-post--count">1</span>10 Tips to Avoid Dry Flaky Winter Skin, Safely</div>
</div>
</div>
<div class="featured-post col-12">
<div class="featured-post--wrapper">
<div class="featured-post--body"><span class="featured-post--count">2</span>10 Ways to Spa at Home</div>
</div>
</div>
<div class="featured-post col-12">
<div class="featured-post--wrapper">
<div class="featured-post--body"><span class="featured-post--count">3</span>13 Healthy Ways Winterize Your Routine</div>
</div>
</div>
<div class="featured-post col-12">
<div class="featured-post--wrapper">
<div class="featured-post--body"><span class="featured-post--count">4</span>18 Things to Love About Our Follain Soap</div>
</div>
</div>
<div class="featured-post col-12">
<div class="featured-post--wrapper">
<div class="featured-post--body"><span class="featured-post--count">5</span><3 at First Site</div>
</div>
</div>
</div>
</div>
And the CSS (SCSS) looks like so :
.featured-posts {
counter-reset: section;
.featured-posts--posts {
.featured-post {
margin-bottom: 40px;
width: 100%;
.featured-post--wrapper {
margin: 0 auto;
}
.featured-post--count {
width: 45px;
float: left;
color: red;
height: 100%;
display: block;
font-size: 30px;
}
.featured-post--body {
width: 350px;
max-width: 100%;
margin: 0 auto;
color: black;
a {
cursor: pointer;
text-decoration: none;
color: black;
transition: color 0.2s ease-in;
&:hover {
color: red;
}
}
}
}
}
}
I am trying to have so no matter what length the text is - it is vertically aligned against the "Count" (the left number). Any input would be welcome! Thanks.
I would use display: flex; align-items: center; on the parent
.wrapper {
margin: 0 auto;
max-width: 600px;
}
.featured-posts {
counter-reset: section;
}
.featured-posts .featured-posts--posts .featured-post {
margin-bottom: 40px;
width: 100%;
}
.featured-posts .featured-posts--posts .featured-post .featured-post--wrapper {
margin: 0 auto;
}
.featured-posts .featured-posts--posts .featured-post .featured-post--count {
width: 45px;
color: red;
height: 100%;
display: block;
font-size: 30px;
}
.featured-posts .featured-posts--posts .featured-post .featured-post--body {
width: 350px;
max-width: 100%;
margin: 0 auto;
color: black;
display: flex;
align-items: center;
}
.featured-posts .featured-posts--posts .featured-post .featured-post--body a {
cursor: pointer;
text-decoration: none;
color: black;
transition: color 0.2s ease-in;
}
.featured-posts .featured-posts--posts .featured-post .featured-post--body a:hover {
color: red;
}
<div class="featured-posts wrapper">
<div class="featured-posts--posts row">
<div class="featured-post col-12">
<div class="featured-post--wrapper">
<div class="featured-post--body"><span class="featured-post--count">1</span>10 Tips to Avoid Dry Flaky Winter Skin, Safely</div>
</div>
</div>
<div class="featured-post col-12">
<div class="featured-post--wrapper">
<div class="featured-post--body"><span class="featured-post--count">2</span>10 Ways to Spa at Home</div>
</div>
</div>
<div class="featured-post col-12">
<div class="featured-post--wrapper">
<div class="featured-post--body"><span class="featured-post--count">3</span>13 Healthy Ways Winterize Your Routine</div>
</div>
</div>
<div class="featured-post col-12">
<div class="featured-post--wrapper">
<div class="featured-post--body"><span class="featured-post--count">4</span>18 Things to Love About Our Follain Soap</div>
</div>
</div>
<div class="featured-post col-12">
<div class="featured-post--wrapper">
<div class="featured-post--body"><span class="featured-post--count">5</span><3 at First Site</div>
</div>
</div>
</div>
</div>
The Above image shows this is how i want to make it.I have alignment display issue and line doesn't gets displayed. how can i achieve using with bootstrap grid.I want it make responsive. please advise where i am making mistake and how can i make it happen.
plunker link
I wan to see like this
<div class="container-fluid" style="background: white;">
<div class="row">
<div class="col-lg-9 col-xs-12 ">
<div class="parent col-md-3 col-xs-3">
<div class="child circle col-md-1 col-xs-1">1</div>
<div class="expenseItems col-md-1 col-xs-1">Text1</div>
<div class="hrcol-md-1 col-xs-1"></div>
</div>
<div class="parent col-md-3 col-xs-3">
<div class="child circle col-md-1 col-xs-1">2</div>
<div class="expenseItems col-md-2 col-xs-2">Text2</div>
<div class="hr col-md-1 col-xs-1"></div>
</div>
<div class="parent col-md-3 col-xs-3">
<div class="child circle col-md-1 col-xs-1">3</div>
<div class="expenseItems col-md-2 col-xs-2">Text3</div>
<div class="hr col-md-1 col-xs-1"></div>
</div>
<div class="parent col-md-3 col-xs-3">
<div class="child circle col-md-1 col-xs-1">4</div>
<div class="expenseItems col-md-2 col-xs-2">Text4</div>
<div class="hr col-md-1 col-xs-1"></div>
</div>
</div>
</div>
CSS
/*For drawing line*/
.hr {
color: gray;
background: gray;
width: 5px;
height: 1px;
margin-top:4px;
}
.circle
{
width: 28%;
border-radius: 100%;
text-align: center;
font-size: 14pt;
padding: 1pt;
position: relative;
background: gray;
color: white;
margin-top:11pt;
}
/*Parent div*/
.parent {
border-style: dashed;
border-width: 1px;
padding: 25px;
display:inline-block;
background-color:Aqua;
}
.child {
float: left;
background-color:Orange;
}
.expenseItems {
display: inline-block;
background-color:Green;
}
Using columns to acheive alignment inside other columns doesn't really make much sense when you can simply use a display property to do this with the content inside a column.
Use display: inline-block and remove all the nested columns.
Working Example: Open at FullPage
/*Use this rule below adjust the space between columns*/
.no-gutter > [class*='col-'] {
padding-right: 1px;
padding-left: 1px;
}
/*Use the above to adjust the space between columns*/
.parent {
border: 1px dashed red;
padding: 20px 25px 25px;
}
.circle {
width: 25px;
height: 25px;
border-radius: 50%;
padding-top: 3px;
display: inline-block;
text-align: center;
background-color: red;
color: white;
}
.expenseItems {
padding: 10px;
display: inline-block;
color: red;
}
.hr {
background: red;
height: 2px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="row no-gutter">
<div class="col-sm-3">
<div class="parent">
<div class="circle">1</div>
<div class="expenseItems">TEXT</div>
<div class="hr"></div>
</div>
</div>
<div class="col-sm-3">
<div class="parent">
<div class="circle">1</div>
<div class="expenseItems">TEXT</div>
<div class="hr"></div>
</div>
</div>
<div class="col-sm-3">
<div class="parent">
<div class="circle">1</div>
<div class="expenseItems">TEXT</div>
<div class="hr"></div>
</div>
</div>
<div class="col-sm-3">
<div class="parent">
<div class="circle">1</div>
<div class="expenseItems">TEXT</div>
<div class="hr"></div>
</div>
</div>
</div>
</div>
So the title pretty much explains my problem. For now, I have my image placed at the top of the column and at the same time I need it to be at the bottom. How can I do this?
My Codepen
HTML
<div class="content">
<div class="row">
<div class="col-md-10 first-column"></div>
<div class="col-md-2 back-to-blog">
<a href="/">
<img class="img-responsive" src="https://api.asm.skype.com/v1/objects/0-neu-d1-6d077751650ba9cb23f065b16e4d4581/views/imgpsh_fullsize">
</a>
</div>
</div>
</div>
</div>
CSS
.content {
padding: 0 35px;
}
.first-column {
border: 1px solid;
height: 200px;
}
Flexbox can do that:
.content {
padding: 0 35px;
}
.row {
display: flex; /* columns now equal height */
}
.first-column {
border: 1px solid;
height: 200px;
flex: 10; /* replicates md-10 */
}
.back-to-blog {
flex: 2; /* replicates md-2 */
display: flex;
flex-direction: column; /* sets directionality */
justify-content: space-between; /* separates elements across direction */
}
a {
display: block;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="content">
<div class="row">
<div class="col-md-10 first-column"></div>
<div class="col-md-2 back-to-blog">
<a href="/">
<img class="img-responsive" src="http://lorempixel.com/image_output/abstract-q-c-25-25-3.jpg">
</a>
<a href="/">
<img class="img-responsive" src="http://lorempixel.com/image_output/abstract-q-c-25-25-3.jpg">
</a>
</div>
</div>
</div>
</div>
Here is another way if you want to stick into Bootstrap column classes:
HTML:
<div class="content">
<div class="row">
<div class="col-xs-2 col-sm-10 col-md-10 first-column">aaa</div>
<div class="col-xs-2 col-sm-2 col-md-2 back-to-blog">
<img class="img-responsive" src="https://api.asm.skype.com/v1/objects/0-neu-d1-6d077751650ba9cb23f065b16e4d4581/views/imgpsh_fullsize">
<img class="img-responsive" src="https://api.asm.skype.com/v1/objects/0-neu-d1-6d077751650ba9cb23f065b16e4d4581/views/imgpsh_fullsize">
</div>
</div>
</div>
</div>
CSS:
.content {
padding: 0 35px;
}
.first-column {
border: 1px solid;
height: 200px;
}
.back-to-blog{
height: 200px;
}
.btm-link{
position: absolute;
bottom: 0;
}
Codepen:
http://codepen.io/anon/pen/xZyGoQ
I've got a lot of trouble with getting my checkboxes vertical aligned in my divs with a dynamic height.
I have some of my view:
<div class="col-md-7">
<div class="row recent-information">
<div class="product-navigation">
<div class="product-header-text">
<div class="col-md-3 product-details">
<p>Product name</p>
</div>
<div class="col-md-4 product-details">
<p>Note</p>
</div>
<div class="col-md-2 product-details">
<p>Price</p>
</div>
<div class="col-md-2 product-details">
<p>Stock</p>
</div>
</div>
</div>
#foreach (var item in Model.Products)
{
<div class="product-header">
<div class="product-header-text">
<div class="col-md-3 product-details-entity">
<h6>#item.Name</h6>
</div>
<div class="col-md-4 product-details-entity">
<h6>#item.Description</h6>
</div>
<div class="col-md-2 product-details-entity">
<h6>#item.Price DKK</h6>
</div>
<div class="col-md-1 product-details-entity">
<h6>#item.Stock</h6>
</div>
<div class="col-md-1 product-details-checkbox">
#Html.CheckBox("naem", new { #class = "products-checkbox" })
</div>
</div>
</div>
}
</div>
</div>
And the style:
.product-header {
min-height: 7%;
min-width: 100%;
margin-bottom: 3px;
border-bottom: 1px solid #e6e6e6;
overflow: hidden;
}
.product-header-text {
width: 98%;
margin-left: 10px !important;
margin-right: 10px !important;
float: left;
font-weight: 700 !important;
margin-bottom: 3px;
height: 100%;
}
.product-details {
font-weight: 500 !important;
margin-top: 13px;
font-family: 'Raleway', sans-serif;
font-size: 12px;
height: auto;
min-height: 100%;
}
.product-details-entity {
margin-top: 20px;
height: auto;
}
input[type="checkbox"] {
background: #f8f8f5;
-webkit-appearance: none;
height: 22px;
width: 22px;
margin-top: 20%;
cursor: pointer;
margin-left: 65px;
}
input[type="checkbox"]:checked {
background-image: url("../Images/checkmark2.png");
height: 22px;
width: 22px;
}
My problem is, that my divs, the product-details are dynamically based on the content from the database, and I can't get my checkboxes to follow.