I need to display each div without any overlaps, the main div is using bootstrap col-*, this same div contains other divs with absolute position, I need to be clear that I cannot altern the height and the width of any div outside .element divs (which means width, height of 100% or auto can still be used).
Here's the fiddle : https://jsfiddle.net/Lmt1u1uw/6/
.layout {
position: relative;
}
.element,
.elements {
position: absolute;
}
.layout-1 .background {
background: #4dadc9;
width: 600px;
height: 400px;
}
.layout-1 .text {
transform: translate(30px, 60px);
color: #ffffff;
width: 200px;
}
.layout-2 .background {
background: red;
width: 600px;
height: 400px;
}
.layout-2 .text {
transform: translate(170px, 200px);
color: #ffffff;
width: 200px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="region col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="layout layout-1">
<div class="elements">
<div class="element background"></div>
<div class="element text">Magic soak into my spine.</div>
</div>
</div>
</div>
<div class="region col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="layout layout-2">
<div class="elements">
<div class="element background"></div>
<div class="element text">The dreams maker gonna make you mad.</div>
</div>
</div>
</div>
As you can see in the snippet the two .region are on top of each other on responsive and shouldn't overlap, how can I fix this ?
The two .elements need to be display:block and have a specified width/height in order to float around each other:
have a look a my fiddle here:
https://jsfiddle.net/Lmt1u1uw/7/
This should do the trick.
Related
I have two flex columns with some content. I want the first column height to always be equal to the height of the second column, and use overflow: auto if it has more content than the other column. One important note is that I don't want to use absolute positioning. Below is what I am after:
.cover {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow-y: auto;
}
.content-1 {
height: 500px;
background-color: green;
}
.content-2 {
height: 150px;
background-color: blue;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="cover">
<div class="content-1"></div>
</div>
</div>
<div class="col">
<div class="content-2"></div>
</div>
</div>
</div>
Is there a way to achieve the same without the absolutely positioned element nested in the first col? Thanks in advance.
Here is an idea I used in a previous question where you can rely on the min-height:100%;height:0; trick. The height:0 will force the element to not affect the height of the container and min-height:100% will force it to be equal to the height defined by the sibling element:
.cover {
height:0;
min-height: 100%;
overflow-y: auto;
}
.content-1 {
height: 500px;
background-color: green;
}
.content-2 {
height: 150px;
background-color: blue;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="cover">
<div class="content-1"></div>
</div>
</div>
<div class="col">
<div class="content-2"></div>
</div>
</div>
</div>
I want to align the image to left, then its title then the text below it.
Here is the screenshot of what I want to make.
I have made DIV for each content. I dont know if its okay to do that.
I made it, because I ll have more control for individual content.
But I havent ben able to do so.
.howtocontainer {
height: 1985px;
width: 1121px;
background-image: url("//azlily.bex.jp/eccube_1/html/template/default/img/howto/background.png");
}
.firstsection {
/*background: rgb(255,255,255,0.3);*/
background: grey;
height: 200px;
position: relative;
top: 300px;
margin: 0 40px 0 40px ;
}
.firstpic {
padding-top: 20px;
}
.firstsecbanner {
float: right;
margin-right: 500px;
margin-top: -15px;
}
<div class ="howtocontainer">
<div class="firstsection">
<div class="firstpic">
<img src="https://images.pexels.com/photos/462118/pexels-photo-462118.jpeg?auto=compress&cs=tinysrgb&h=350">
</div>
<div class="firstsecbanner">
<img src="https://images.pexels.com/photos/462118/pexels-photo-462118.jpeg?auto=compress&cs=tinysrgb&h=350">
</div>
<div class="firstsectext">
お好みの量(目安はピンポン玉大です)を手に取って、パートナーの性感帯を指の腹や手のひらで優しくマッサージ<br>
してください。<br>
最初は背中や首筋、そして胸などと、段々と敏感な部分へ伸ばしていくと、ヌルヌルと滑る感覚が気持ちよく、エロ<br>
ティックな気分を高めることができます。<br><br>
性感帯は塗った部分が敏感になり、ただ触れるだけでも極上の気持ち良さ。<br>
シュチュエーションに合わせてラブローションの香りを変えたりしながら楽しみ方を<br>
見つけてください。
</div>
</div>
<div class="secondsection"></div>
<div class="thirdsection"></div>
</div>
All I did was Included image and text in one DIV
But gave a class to image by <img class="class" src"path" >
Then I did float:left to .img class.
There are 2 key points that you should notice about using float:
Float container should be set a specific width (absolute or relative width)
clear all floating items
You should change your HTML structure a little bit, and add some CSS styles:
.firstpic {
float: left;
width: 300px; /*this width is equal with its image's width */
}
.description {
float: left;
width: calc(100% - 300px);
}
/* Clear floating item */
.firstsection::after {
display: table;
content: "";
clear: both;
}
<div class="firstsection">
<div class="firstpic">
<img src="the-image-on-left-side">
</div>
<div class="description">
<div class="firstsecbanner">
<img src="the-title-image-on-top">
</div>
<div class="firstsectext">
お好みの量(目安はピンポン玉大です)を手に取って、パートナーの性感帯を指の腹や手のひらで優しくマッサージ<br>
してください。<br>
最初は背中や首筋、そして胸などと、段々と敏感な部分へ伸ばしていくと、ヌルヌルと滑る感覚が気持ちよく、エロ<br>
ティックな気分を高めることができます。<br><br>
性感帯は塗った部分が敏感になり、ただ触れるだけでも極上の気持ち良さ。<br>
シュチュエーションに合わせてラブローションの香りを変えたりしながら楽しみ方を<br>
見つけてください。
</div>
</div>
</div>
Please add absolute URL instead of relative URL to see your pictures.
Hope this helps.
A disadvantage of using floats is that it disturbs the natural document flow. You may want to consider an alternative using flexbox.
.firstsection {
display: flex;
}
.firstpic {
width: 300px;
/*this width is equal with its image's width */
}
.description {
width: calc(100% - 300px);
}
<div class="howtocontainer">
<div class="firstsection">
<div class="firstpic">
<img src="//azlily.bex.jp/eccube_1/html/template/default/img/howto/01.jpg">
</div>
<div class="description">
<div class="firstsecbanner">
<img src="//azlily.bex.jp/eccube_1/html/template/default/img/howto/firstsecbanner.png">
</div>
<div class="firstsectext">
お好みの量(目安はピンポン玉大です)を手に取って、パートナーの性感帯を指の腹や手のひらで優しくマッサージ<br> してください。
<br> 最初は背中や首筋、そして胸などと、段々と敏感な部分へ伸ばしていくと、ヌルヌルと滑る感覚が気持ちよく、エロ
<br> ティックな気分を高めることができます。
<br><br> 性感帯は塗った部分が敏感になり、ただ触れるだけでも極上の気持ち良さ。
<br> シュチュエーションに合わせてラブローションの香りを変えたりしながら楽しみ方を
<br> 見つけてください。
</div>
</div>
</div>
<div class="secondsection"></div>
<div class="thirdsection"></div>
</div>
Here is the plunkr:
The issue is for this div
https://plnkr.co/edit/HHsReAT6GLyNZTF4qOJj?p=preview
<div class="main-page">
<div class="container">
<div class="row">
<div class="col-xs-6 welcome-text">Ankur Chavda</div>
<div class="col-xs-4 intro">Programmer, Singer Song-Writer, Football</div>
</div>
</div>
</div>
You can see the css classes in plunkr.
Thanks in advance.
Remove the line height from:
.main-page {
background-color: #293b4d;
width: 100%;
height: 90vh;
/* text-align: center; */
/* vertical-align: middle; */
}
if you really want those two div elemnts to centered be to the main-page you can try this:
.main-page{
background-color: #293b4d;
width: 100%;
height: 90vh;
/* text-align: center; */
/* vertical-align: middle; */
position:relative;
}
.holder {
width: 100%;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
And then add another div element with class named "holder" as a parent of the row like this:
<div class='holder'>
<div class="row">
<div class="col-xs-6 welcome-text">Ankur Chavda</div>
<div class="col-xs-4 intro">Programmer, Singer Song-Writer, Football</div>
</div>
</div>
Hope that will work.
Here is a screenshot:
How can I align div element at the bottom of parent element while using bootstrap col?
.wrapper {
background-color: green;
height: 200px;
}
.bottom {
position: relative;
}
.bottom-div {
height: 200px;
position: absolute;
bottom: 0;
}
<div class="wrapper">
<div class="col-md-3 bottom">
<div class="bottom-div"> TEST1 </div>
</div>
<div class="col-md-6">
TEST2
</div>
<div class="col-md-3">
TEST3
</div>
</div>
bottom div element does not align at bottom. What is correct way of doing this? Thanks.
UPDATE: Div element runs out of wrapper (it basically moves up)
Not sure exactly what you're trying to do, as #CBroe said flexbox would be the best way but try this:-
/* CSS used here will be applied after bootstrap.css */
.wrapper{
background-color:green;
height: 200px;
position: relative;
}
.bottom-div{
height: 50px;
width: 50px;
position: absolute;
bottom:0;
left: 0;
background-color: red;
}
.testclass {
height: 100%;
}
<div class="wrapper">
<div class="col-md-3 testclass">
<div class="bottom-div"> TEST1 </div>
</div>
<div class="col-md-6">
TEST2
</div>
<div class="col-md-3">
TEST3
</div>
</div>
I would like to have a collapsible sidebar in bootstrap.
For this I' d like to have a slim element between the content and the sidebar toggles the visibility of the sidebar (display property). See the example below:
https://jsfiddle.net/zaao8Lqb/1/
Instead of the border (as in the fiddle), I' d like to have an element. How would I do that?
The solution is a simple div with full height. The total solution of a collapsible sidebar:
https://jsfiddle.net/c2bgkbzL/1/
html,
body {
height: 100%;
}
.fill {
height: 100%;
min-height: 100%;
}
#content {
background-color: AliceBlue;
height: 100%;
padding-left: 0;
}
#sidebar {
background-color: DarkGray;
height: 100%;
padding: 3px;
}
#collapseme{
background-color: black;
width: 10px;
height: 100%;
float: left;
}
Here is the code to do it. Can find fiddle at https://jsfiddle.net/qaisarnadeem/zzs94oc1/
<body>
<div class="container-fluid fill">
<div class="row fill">
<div class="col-lg-2 col-md-4 col-xs-4" id="sidebar">
<h4>
Sidebar
</h4>
</div>
<div class="pull-left vertical-elem"></div>
<div class="col-lg-10 col-md-6 col-xs-6 text-center" id="content">
<h3>
Content
</h3>
</div>
</div>
</div>
</body>
here is css for class vertical-elem
.vertical-elem{
height:100%;
width:6px;
background-color:blue;
}