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.
Related
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>
My code structure looks like this
<div style="height: 100px;
Width: 200px;"> <!-- Container -->
<div style="float: left;
height: 50px;
Width: 100px;
background-color: red;">
</div>
<div style="float: left;
height: 50px;
Width: 100px;
background-color: blue;">
</div>
<div style="float: right;
height: 50px;
Width: 100px;
background-color: green;">
</div>
</div>
But the right position of elements should look like this:
┌──────┬──────┐
│ red │green │
├──────┼──────┘
│ blue │
└──────┘
I cannot change or add any additional code, the only way is with CSS.
How should I float the divs to be in the right order as I mentioned above?
Edit: My code doesn't and can't contain div with clear.
you dont need floating for that. disable all floating using !important to override the inline styles, and then use :nth-of-type() to select the green div and position it absolutely with right and top equal 0;
div {
position: relative;
}
div > div{
float: none !important;
}
div > div:nth-of-type(3) {
position: absolute;
right: 0;
top:0;
}
<div style="height: 100px; Width: 200px;">
<!-- Container -->
<div style="float:left; height: 50px; Width:100px; background-color:red;">
</div>
<div style="float:left; height: 50px; Width:100px; background-color:blue;">
</div>
<div style="float:right; height: 50px; Width:100px; background-color:green;">
</div>
</div>
You can use clear: left on the blue box to push it down and then use negative margin on the green box to push it up.
<div style="height: 100px; Width: 200px;">
<!-- Container -->
<div style="float:left;height: 50px;
width:100px; background-color:red;">
</div>
<div style="float:left;clear:left;
height: 50px; Width:100px; background-color:blue;">
</div>
<div style="float:left; height:50px;
width:100px; background-color:green;margin-top:-50px;">
</div>
</div>
Well this is more like a puzzle instead of a legit question but here goes.
With the proper use of margins and positions in addition to assigning null to clear property one can accomplish your scenario.
<div style="height: 100px; Width: 200px;">
<!-- Container -->
<div style="float:left; height: 50px; Width:100px; background-color:red;"></div>
<div style="float: right; height: 50px; margin-top: 50px;Width:100px; background-color:blue;position: absolute;"></div>
<div style="clear: none;"></div>
<div style=" height: 50px; margin-left: 100px;margin-bottom: 50px;Width:100px; background-color:green;"></div>
</div>
</div>
Keeping the same HTML structure, you could select the divs in CSS using :nth-child(N). In this case you'd just need to update the blue (2) and green (4) boxes, and the one with the clear:both style (3):
div > div:nth-child(2) {
margin-top: 50px;
}
div > div:nth-child(3) {
display: none;
}
div > div:nth-child(4) {
margin-top: -100px;
}
<div style="height: 100px; Width: 200px;">
<!-- Container -->
<div style="float:left; height: 50px; Width:100px; background-color:red;">
</div>
<div style="float:left; height: 50px; Width:100px; background-color:blue;">
</div>
<div style="clear:both;"></div>
<div style="float:right; height: 50px; Width:100px; background-color:green;">
</div>
</div>
Notice that this will work for this particular example. It would be ideal if the container div had an id and use that instead of div >.
For a more generic solution that would work independently of the height of the boxes, you could use transform:translate() like this:
div > div:nth-child(2) {
transform:translate(0%, 100%);
}
div > div:nth-child(3) {
display:none;
}
div > div:nth-child(4) {
transform:translate(0%, -100%);
}
As you can see on this JSFiddle: http://jsfiddle.net/eekhjv3n/1/
http://i.imgur.com/Veauoig.png
I am currently trying to work out how to make the 'From £' text to keep in the same position as the buttons above. The page is responsive so I have been unable to keep the text in one position.
The CSS I have used so far -
element.style {position: absolute; width: 97%;}
I put each of the 'From £' parts in their own class. Not sure if there is an easier way?
<div class="price2">From £300</div>
Any help would be great. Thanks!
Add a container for the element for the price and button so that they remain in context with each other.
http://jsfiddle.net/05orkj1a/
.prices{
width: 100%;
}
.price-column{
display: table-cell;
width: 33%;
text-align: center;
margin: 0 auto;
padding: 0 5px;
}
<div class="prices">
<div class="price-column">
<button>Bass</button>
<div class="price2">From £65</div>
</div>
<div class="price-column">
<button>Mid</button>
<div class="price2">From £300</div>
</div>
<div class="price-column">
<button>Treble</button>
<div class="price2">From £715</div>
</div>
</div>
You could also Float the columns left to cause them to collapse vertically as the screen shrinks with the same html. Just change the margin or padding depending on how far apart you want them spaced
http://jsfiddle.net/z6agt11e/
.prices{
width: 100%;
overflow: hidden;
}
.price-column{
display: block;
float: left;
text-align: center;
padding: 5px 5px;
}
You can also add an outer container and then create a inner container for each button-price set.
Here is the HTML code:
<div class="outter">
<div class="block">
<div class="button">button1</div>
<div class="price2">From £65</div>
</div>
<div class="block">
<div class="button">button2</div>
<div class="price2">From £300</div>
</div>
<div class="block">
<div class="button">button3</div>
<div class="price2">From £715</div>
</div>
</div>
Here the CSS:
.outter{
width:100%;
}
.block{
width:33%;
background-color: yellow;
float:left;
text-align: center;
}
And here a jsfiddle:
http://jsfiddle.net/SoniaGM/ej4mdwx9/1/
Hope it helps.
You can use the CSS3 ::after pseudo-selector.
Give at button class:
position: relative;
Then you have to write something lime this:
.button-class::after {
content: 'From £300';
background: transparent;
height: 1%;
width: 3%;
position: absolute;
top: 20px;
left: 0px;
}
Obviously, you have to change height: 1%; width: 3%; and top: 20px; left: 0px;with whatever you want!
I am trying to get the picture in the 2nd div to overflow the parent div. I have played around with different position attributes and overflow:visible, but none seem to solve my issue.
How can I solve this?
Thanks
EDIT: Okay scrap that first code - here is the actual code:
I want to get the slider to stretch across and overflow the sp_block
EDIT 2: I must not edit the first 4 divs by the way.
<div id="sp_header">
<div id="sp_block_16" class="sp_block_section_last">
<div>
<div class="sp_block">
<!--
must have
-->
<link type="text/css" rel="stylesheet" href="http://www.dedicatedrejects.com/icsa/test/slider/allinone_contentSlider.css"></link>
<link type="text/css" rel="stylesheet" href="http://fonts.googleapis.com/css?family=Cabin"></link>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://www.dedicatedrejects.com/icsa/test/slider/js/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript" src="http://www.dedicatedrejects.com/icsa/test/slider/js/allinone_contentSlider.js"></script>
<!--
must have
-->
<script></script>
<div style="position:relative; width:1562px; height:351px; overflow:visible;">
<div style="width:1562px; height:351px; position:absolute; overflow:visible; margin: 0 auto;">
<div class="allinone_contentSlider imposing" style="width: 1562px; height: 351px;">
<div id="allinone_contentSlider_imposing" style="position:relative overflow:visible;"></div>
<div class="bottomNavRight" style="display: block; bottom: -35px; top: auto; left: 813px;"></div>
<div class="bottomNav" style="display: block; bottom: -35px; top: auto; width: 46px; left: 758px;"></div>
<div class="bottomNavLeft" style="display: block; bottom: -35px; top: auto; left: 758px;"></div>
<div class="bannerControls" style="margin-top: 105px;"></div>
<div class="contentHolderVisibleWrapper" style="width: 1562px; height: 351px;">
<div class="contentHolder ui-draggable" style="cursor: url("skins/hand.cur"), url("skins/hand.cur"), move; … top: 0px; position: absolute; width: 3124px; height: 351px;">
<div id="contentHolderUnit_0" class="contentHolderUnit" rel="0" style="width: 1562px; height: 351px;">
<img src="https://robertsspaceindustries.com/media/6kahqz455yu40r/post_section_header/StarCitizenDev-2014-04-11-14-10-32-75.jpg" style="position:absolute;"></img>
<img src="http://i.imgur.com/vcifs31.png" style="position:absolute; z-index:10;"></img>
</div>
<div id="allinone_contentSlider_photoText0" class="allinone_contentSlider_texts" style="z-index: 11; width: 1562px; left: 0px; top: 0px; display: none;"></div>
<div id="contentHolderUnit_1" class="contentHolderUnit" rel="1" style="width: 1562px; height: 351px;"></div>
<div id="allinone_contentSlider_photoText1" class="allinone_contentSlider_texts" style="z-index: 11; width: 1562px; left: 1562px; top: 0px; display: none;"></div>
</div>
</div>
<div class="playOver" style="left: 744px; top: 139px; display: none;"></div>
<canvas class="mycanvas" width="36" height="36"></canvas>
</div>
</div>
</div>
</div>
</div>
</div>
As it is, the image will appear outside the parent div, for no overflow has been specified. If you want it to hide inside the parent div, just add to the div:
{
overflow: hidden;
}
http://jsfiddle.net/Cn3n3/2/
The inline width and height attributes (within the <img> tag) shouldn't have the px unit in them. Only specify the number of pixels without a unit. You shouldn't need to specify overflow, since the defaults will suit your needs in this case.
See example: http://jsfiddle.net/orvn/ansBc/1/
<div id="container">
<img src="http://foo.com/image.jpg" width="500">
</div>
#container { width: 300px; }
#container > img { display: block; }
Additionally, you don't need to wrap the image in a div here, you can apply display: block; to have it behave the way a div would.
Not sure what you're trying to achieve but the parent div needs the overflow tag.
HTML
<div class="parent">
<div class="child">image</div>
</div>
CSS
.parent {
width:700px;
height:200px;
overflow:visible;
background-color:green;
}
.child {
width:1000px;
height:100px;
background-color:red;
}
Here is a demo jsfiddel
I made the parent div background height longer so you can see the overflow. You can also replace the background color with an image. Replace the class (parent & Child) and write this inline but I advise against that.
I´m trying to place a slided image in the center if the page. I have it almost done, the thing is that inner each piece of the image I have a small space, like if it has some little padding (which it hasn't), does anybody sees something wrong in the code?
<style type="text/css">
html, body, #wrapper, images {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px;
border: 0px;
background-color: #000;
}
img {
margin: 0px;
padding: 0px;
border: 0px;
}
.center {
width: 800px;
height: 600px;
position: absolute;
left: 50%;
top: 50%;
margin-left: -400px;
margin-top: -300px;
}
.center_mini {
margin: 0px;
padding: 0px;
border: 0px;
}
.center_mini_float {
float: left;
margin: 0px;
padding: 0px;
border: 0px;
}
</style>
<div class="center">
<div class="center_mini">
<img src="images/background_01.png" width="800" height="144" alt="bg">
<div class="center_mini">
<div class="center_mini_float">
<img src="images/background_02.png" width="503" height="456" alt="bg">
</div>
<div class="center_mini_float">
<div class="center_mini">
<div class="center_mini">
<img src="images/background_03.png" width="246" height="89" alt="bg">
</div>
<div class="center_mini">
<img src="images/background_05.png" width="246" height="106" alt="bg">
</div>
<div class="center_mini">
<img src="images/background_06.png" width="246" height="102" alt="bg">
</div>
<div class="center_mini">
<img src="images/background_07.png" width="246" height="159" alt="bg">
</div>
</div>
</div>
<div class="center_mini_float">
<img src="images/background_04.png" width="51" height="456" alt="bg">
</div>
</div>
</div>
<!--<img src="images/background.jpg" width="800" height="600" alt="bg">-->
</div>
Try adding:
img { display: block; }
The problem is that IMG tags have a natural DISPLAY value of "INLINE". This causes extra whitespace to appear around the image in certain situations.
Depending on your layout needs, try
img { display: block; }
or
img { display:inline-block; }
If your images are otherwise working the way you want, inline-block will cause the least amount of thrash.
More info:
http://www.w3schools.com/cssref/pr_class_display.asp
http://www.tequilafish.com/2009/04/29/css-removing-extra-space-underneath-an-image/
I think the better solution will be using
img { vertical-align: middle; }
This way you won't alternate the default browser image display. Also, make sure the image container has line-height: 100%, that could be causing problems too.
Images have display:inline; by default, that's what's causing the whitespace between your images. You can do three things to prevent this:
float:left;
or
display:inline-block;
or
display:block;