I am trying to achieve facebook alike image cover as follow, but unable to achieve desire effect. This is the css that i have try. As you all can see, the div content does not position correctly.
.profile {
position: relative;
}
.profile-cover img{
width: 100%;
}
.profile-photo {
position: absolute;
left: 20px;
bottom: -60px;
}
.profile-info {
padding-right: 120px;
}
<div class="profile">
<div class="profile-cover">
<img src="http://dummyimage.com/1200x300/000/fff" />
</div>
<div class="profile-details">
<div class="profile-photo">
<img src="http://dummyimage.com/100x100/eee/000" />
</div>
<div class="profile-info">
Profile info here
</div>
</div>
</div>
<div>
Remaining content here
</div>
I am not exactly sure if you wanted this because you just say the "the div content does not position correctly", but I'm quiet sure it's that.
So, if not, tell me.
Using the absolute positioning gets out of the flow the element. So, the next ones continues as if this element didn't exist. That's why the others were showing under this absolute element.
For next time, please precise which DIV by using its id, a class name or anything that we can know for sure the one you are talking about.
.profile {
position: relative;
}
.profile-cover img{
width: 100%;
}
.profile-photo {
display: inline-block;
margin-top: -60px;
margin-left: 20px;
}
.profile-info {
display: inline-block;
padding-right: 120px;
}
<div class="profile">
<div class="profile-cover">
<img src="http://dummyimage.com/1200x300/000/fff" />
</div>
<div class="profile-details">
<div class="profile-photo">
<img src="http://dummyimage.com/100x100/eee/000" />
</div>
<div class="profile-info">
Profile info here
</div>
</div>
</div>
<div>
Remaining content here
</div>
This is how I would do it ...
.profile {
margin-bottom: 15px;
}
.profile-cover img {
width: 100%;
}
.profile-photo {
display: inline-block;
margin-left: 20px;
margin-top: -24px;
}
.profile-info {
display: inline-block;
position: relative;
top: -25px;
left: 10px;
}
<div class="profile">
<div class="profile-cover">
<img src="http://dummyimage.com/1200x300/000/fff" />
</div>
<div class="profile-details">
<div class="profile-photo">
<img src="http://dummyimage.com/100x100/eee/000" />
</div>
<div class="profile-info">
Profile info here<br>
More info here
</div>
</div>
</div>
<div>
Remaining content here
</div>
Related
I am facing a problem in placing divs relatively with each other. I placed them 3 in a row and 3 in each column (the first column is 140px, 2nd is 320px and 3rd is 500px from the left) with each other by pixel formatting in 100% window size but it needs scrolling to see them in any other window size. I want it to arrange themselves accordingly as the window size changes. The code I wrote is given as follows
#box1 {
color: white;
background-color: #ac536f;
position: relative;
display: inline-block;
width: 210px;
height: 162px;
left: 140px;
}
#box2 {
color: white;
background-color: #ac536f;
position: relative;
display: inline-block;
width: 210px;
height: 162px;
left: 320px;
}
#box3 {
color: white;
background-color: #ac536f;
position: relative;
display: inline-block;
width: 210px;
height: 162px;
left: 500px;
}
<div id="box1">
<img src="thumbnail1.jpg" />DIV1
</div>
<div id="box2">
<img src="thumbnail2.jpg" />DIV2
</div>
<div id="box3">
<img src="thumbnail3.jpg" />DIV3
</div>
<br/><br/>
<div id="box1">
<img src="thumbnail4.jpg" />DIV4
</div>
<div id="box2">
<img src="thumbnail5.jpg" />DIV5
</div>
<div id="box3">
<img src="thumbnail6.png" />DIV6
</div>
<br/><br/>
<div id="box1">
<img src="thumbnail7.jpeg" />DIV7
</div>
<div id="box2">
<img src="thumbnail8.png" />DIV8
</div>
<div id="box3">
<img src="thumbnail9.png" />DIV9
</div>
<br/><br/>
• You should read up on flex-box. The flex-box does the layout for you and sorts out any kind of wrapping.
• You should never use <br/> if you want to do the page responsive. Let the CSS take care of any row wrapping.
• Using id is just for unique objects. Use CSS classes instead if you want to apply the same CSS to several elements.
I made the boxes 60x60px to easier display the wrapping on smaller devices.
.box-container {
display: flex;
flex-wrap: wrap;
}
a.box {
width: 60px;
height: 60px;
margin-left: 140px;
margin-bottom: 20px;
color: white;
background-color: #ac536f;
}
<div class="box-container">
<a class="box" href="https://www.youtube.com/watch?v=OUksMAlXQ9w"><img src="thumbnail1.jpg" />DIV1</a>
<a class="box" href="https://www.youtube.com/watch?v=5hEMAPoW3B8"><img src="thumbnail2.jpg" />DIV2</a>
<a class="box" href="https://www.youtube.com/watch?v=iINlkySuCDI"><img src="thumbnail3.jpg" />DIV3</a>
<a class="box" href="https://www.youtube.com/watch?v=zXB5jeceKic"><img src="thumbnail4.jpg" />DIV4</a>
<a class="box" href="https://www.youtube.com/watch?v=tK4pTRySWCM"><img src="thumbnail5.jpg" />DIV5</a>
<a class="box" href="https://www.youtube.com/watch?v=tdH68x36Vxc"><img src="thumbnail6.png" />DIV6</a>
<a class="box" href="https://www.youtube.com/watch?v=_al3HCUNrKo"><img src="thumbnail7.jpeg" />DIV7</a>
<a class="box" href="https://www.youtube.com/watch?v=ua5rZXKj4q0&t=27s"><img src="thumbnail8.png" />DIV8</a>
<a class="box" href="https://www.youtube.com/watch?v=M6PgE_igVz8"><img src="thumbnail9.png" />DIV9</a>
</div>
You can set the height to :
height: 30vh;
That means you set the height to 30% of the screen what the user sees
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>
.wrapper {
width: 100%;
height: 150px;
}
.iconBar div {
float: left;
font-size: 18px;
}
div.iconBar {
display: table;
margin: 0 auto;
}
.iconBar img {
height: 35px;
width: 35px;
vertical-align: middle;
}
<div class="wrapper">
<div class="iconBar">
<div>
<img src="http://eventtoursolutions.com/wp-content/uploads/2017/02/convenient.png"> Convinient, All-Inclusive Weekly Price
</div>
<div>
<img src="http://eventtoursolutions.com/wp-content/uploads/2017/02/Insurance.png"> Insurance
</div>
<div>
<img src="http://eventtoursolutions.com/wp-content/uploads/2017/02/mileage.png"> Milage Allowance & Expenses
</div>
<div>
<img src="http://eventtoursolutions.com/wp-content/uploads/2017/02/tractorTrailer.png"> Tractor & Expandable Trailer
</div>
<div>
<img src="http://eventtoursolutions.com/wp-content/uploads/2017/02/professionalDriver.png"> Professional Driver
</div>
</div>
</div>
Why is my div not centering? I am having trouble making the div center. I tried a bunch of solutions from other people and i got it to work in one of the tests, but this one is not working?
Edit: iconBar Div, i want the text and icons to be centered. It needs to look like the bottom picture
Going by your image remove float:left and add display: inline-block; to .iconBar div {...} and add text-align: center; to div.iconBar {...}
.wrapper {
width: 100%;
height: 150px;
}
.iconBar div {
display: inline-block;
font-size: 18px;
}
div.iconBar {
display: table;
text-align: center;
margin: 0 auto;
}
.iconBar img {
height: 35px;
width: 35px;
vertical-align: middle;
}
<div class="wrapper">
<div class="iconBar">
<div>
<img src="http://eventtoursolutions.com/wp-content/uploads/2017/02/convenient.png"> Convinient, All-Inclusive Weekly Price
</div>
<div>
<img src="http://eventtoursolutions.com/wp-content/uploads/2017/02/Insurance.png"> Insurance
</div>
<div>
<img src="http://eventtoursolutions.com/wp-content/uploads/2017/02/mileage.png"> Milage Allowance & Expenses
</div>
<div>
<img src="http://eventtoursolutions.com/wp-content/uploads/2017/02/tractorTrailer.png"> Tractor & Expandable Trailer
</div>
<div>
<img src="http://eventtoursolutions.com/wp-content/uploads/2017/02/professionalDriver.png"> Professional Driver
</div>
</div>
</div>
I would like to know if it's possibile to trasform a web page like this:
to this:
?
Some code used, under development, to obtain first image:
/** CSS **/
div.Testata35, div.Testata25, div.Testata70Inner, div.Testata29Inner, div.Testata15Inner {
background-color: #C0C0C0;
float: left;
}
div.Testata35, div.Testata25 {
margin-bottom: 0.2%;
margin-right: 1%;
margin-top: 0.2%;
padding-bottom: 0.2%;
padding-left: 1%;
padding-top: 0.2%;
}
div.Testata35 {
width: 35.5%;
}
div.Testata25 {
width: 23%;
}
div.Valore35, div.Valore25 {
float: left;
margin-top: 0.2%;
overflow: auto;
padding-bottom: 0.2%;
padding-left: 1%;
padding-top: 0.2%;
}
div.Valore35 {
margin-right: 2.5%;
width: 34%;
}
div.Valore25 {
margin-right: 1%;
width: 23%;
}
<!-- HTML -->
<div class="ClrOvFlw">
<div class="PrimaSx">
<div class="ClrOvFlw">
<div id="T1" class="Testata35">Modello</div>
<div id="T1A" class="Testata35">Linea</div>
<div id="T2" class="Testata25A">
<div style="clear: left; float: left; width: 70%;">Standard</div>
<div style="clear: right; float: right; width: 20%; z-index: 1; overflow: auto;">
<img id="V25BImg" src="./FotoNorma/standard01-ITA.jpg" alt="Marchio Normativa">
</div>
</div>
<div class="ClrOvFlw">
<div id="V1" class="Valore35">BELLARIA</div>
<div id="V1A" class="Valore35">MODULAR</div>
<div id="V2" class="Valore25A">EN ISO 20345:2011</div>
</div>
</div>
<div class="Valore25B">
</div>
</div>
<div class="ClrOvFlw">
<div id="T3" class="Testata35">Codice Articolo</div>
<div id="T4" class="Testata35">Protezione</div>
<div id="T5" class="Testata25">Disponibilità a Magazzino</div>
</div>
<div class="ClrOvFlw">
<div id="V3" class="Valore35">83297-07LL</div>
<div id="V4" class="Valore35">S1P SRC</div>
<div id="V5" class="Valore25">
<img id="V5Img" src="FotoMagazzino\maga2-ITA.jpg" alt="Disponibilità">
</div>
</div>
As you can see, I've tried some stuff to achieve the result shown in the second image but with no success.
As side note: I'm not a professional HTML/CSS developer so my "code" is not written as the best practice hints.
EDIT:
As suggested by many of you, I've update my code in this way:
<div class="ClrOvFlw">
<div id="T1" class="Testata35">Modello</div>
<div id="T1A" class="Testata35">Linea</div>
<div id="T2" class="Testata25A">
<div style="float: left; clear: left;">Standard</div>
<div class="Valore25B" style="float: right; clear: right; position: relative;">
<img id="V25BImg" src="./FotoNorma/standard01-ITA.jpg" alt="Marchio Normativa" style="position: absolute; display : block; width: 100%; height: 100%;">
</div>
</div>
</div>
Same CSS as above. My results:
EDIT 2:
following suggestions of Fils I've updated my code as follows:
<div id="T2" class="Testata25A">
<div style=" clear: left; float: left;">Standard</div>
<div class="Valore25B" style="position: relative; overflow: auto;">
<img id="V25BImg" src="./FotoNorma/standard01-ITA.jpg" alt="Marchio Normativa" style="position: absolute; right: 0px;overflow: visible; height: 100px;">
</div>
</div>
getting this result:
I guess that I'm doing something wrong in following your hints folks.
You could use position:absolute; on that image if you can gurantee that there is always enough space that the whole image will be displayed:
div#V25BImg{
display:block;
position:absolute;
width:[WIDTH]px;
height:[HEIGHT]px;
}
Also you might need to add position:relative; on the parent of the image to ensure that the absolute positioned element will be placed on the correct part of your page.
Set the image holder to position absolute:
This is untested but should give you an idea
<div style="position: absolute; top: 0; right: 0; width: 20%; z-index: 1; overflow: auto;">
<img id="V25BImg" src="./FotoNorma/standard01-ITA.jpg" alt="Marchio Normativa">
</div>
If you position your img absolutely, it will ignore wrapping.
div #V5 img {
position:absolute;
right:0px;
}
Maybe you can do by adding position: relative; in the div wrapping the image, and adding
position: absolute;
top: 25px;
margin-left: 10px;
to the image. Your code should look like this,
<div style="width: 20%;position: relative;">
<img id="V25BImg" src="logo.png" alt="Marchio Normativa" data-pin-nopin="true" style="position: absolute;top: 25px; margin-left: 10px;
">
</div>
check this out
https://jsfiddle.net/1w772kgg/1/
If you need a correct solution, do not use absolute positioning unless absolutely necessary. A floating element can be floating out from its parent container, if:
parent is overflow:auto, and
no relevant clearing object is placed after the element (same-side CSS clear, too wide line, overflow:hidden block element etc.)
See float rules here.
Try provide this conditions.
I want to make a responsive design with different images, for example:
<div id="home" class="page">
<div id="home_1" class="section"><!-- Page 1 -->
<div id="home_1_1" class="full">
<img src="images/home/home_1/home_1.png" class="full-image"></img>
</div>
</div>
<div id="home_2" class="section"><!-- Page 2 -->
<div id="home_2_1" class="full">
<img src="images/home/home_2/home_2_block1.png" class="full-image"></img>
</div>
<div id="home_2_2" class="full">
<img src="images/home/home_2/home_2_block2.png" class="full-image"></img>
</div>
</div>
<div id="home_3" class="section"><!-- Page 3 -->
<div id="home_3_1" class="full">
<img src="images/home/home_3/home_3_block1.png" class="full-image"></img>
</div>
<div id="home_3_2" class="full">
<img src="images/home/home_3/home_3_block2.png" class="full-image"></img>
</div>
</div>
</div>
home_1, home_2 and home_3 are seperate image blocks. but home_2_1 home_2_2 should have the same top position and they also should be below home_1.
this is my css:
#home{
width: 100%;
text-wrap: none;
white-space: nowrap;
}
.section{
position: relative;
display: inline-block;
width: 100%;
}
.full{
position: absolute;
top:0;
left:0;
}
.full-image{
width: 100%;
display: block;
}
The problem is that I see only one image, the others don't floats beside each other.
I hope somebody can help me with this.
I'm not quite sure what you mean, but have you tried just using floats?
Check this fiddle: http://jsfiddle.net/9Ryby/
.section {
clear: both;
}
.full-image {
width: 50%;
float: left;
}