div width and height alignment for all levels of zooming - html

Html code:
<div class="CorpPerformance">
<div class="row">
<div class="DashboardTitle">
3 Month
</div>
<div class="DashboardScore" style="font-weight:bold">
<a class="redirectLink" data-criteria-corporatesummarycategory="none" data-criteria-corporatesummaryexpand="0" data-criteria-customerpay="" data-criteria-expressservice="" data-criteria-maintenanceplan="" data-criteria-modelname="" data-criteria-rspenddate="" data-criteria-rspstartdate="" data-criteria-warrantypay="" data-criteria-yearmodel="" data-criteria-department="Sales" data-criteria-reportperiod="[Collection Date].[Calendar].[Calendar Month].&[October 2014]" data-criteria-summaryperiod="3MONTH" href="/Corporate/OFSSurveySummary">950</a>
</div>
<div class="DashboardIcon">
<a class="bootstrap-modal" data-criteria-chartcustomerpay="" data-criteria-chartexpressservice="" data-criteria-chartmaintenanceplan="" data-criteria-chartmodelname="" data-criteria-chartmodelyear="" data-criteria-chartwarrantypay="" data-criteria-chartdepartment="SALES" data-criteria-chartmeasurename="Response Default Computation" data-criteria-chartmeasuretype="score" data-criteria-chartorganization="" data-criteria-chartpagetitle="NSSI Trend" data-criteria-chartreportperiod="[Collection Date].[Calendar].[Calendar Month].&[October 2014]" data-criteria-chartsummaryperiod="3MONTH" data-criteria-charttitle="NSSI" data-criteria-chartwheretuple="[Questionnaire].[Questionnaire].[Question].&[OFSP]&[OFSP13011]" href="/Trend" modal-no-resize="True" upper="NSSI Trend"><span>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAAAZCAYAAACM9limAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHxSURBVFhH7Zg9SEJRFMcdW4QmcRI3xclNcYiGBocGB4dqMQTXdHdoFRqsoCAtJEiMKCpCHkHkECFJUNQgNqgEIQ19DIFBw8n/8SkUPft66n31fnBArnLh/O69556roQHp8WEYSOctuhgFhBdTLN5RLndN2WxZHukNQoopFGrk9W6S1Zogu32FhofXyeFI0cBAnHy+HUqlLunh4Vn+dWfq9RcWG4+f0sjIBnk8aZ5vcHC+kfgMz/URQolBspHIIdlsyxSLnVCl8ih/0wRJbm9f0eSkREbjHJlMC5wkYmIiS4GAxEJbY2bzIsvEZ8w7O3vKkhCfiRVGDFYOuwMr+1Vqtad2oonEOU1NHZAkldtj78V+h76LyedvWIjfv8uJikLfxGA1x8b2yO1O8+qKRs/FYFeMjm5xHclkivKoePRMTKuw4qaZnj7mQioyPRETDjeFoLCKLqRF18XgGh0f3/ty3yEKXRODnYGeQqmBEp2uiMHuQIeKnkKrqC6mVLqnoaGMpqUAVcXg+rVYlrht1zqqiMHRwfsFDZvWiqwSvxaTTF5wS6/VIqvEj8Wcnd3yq9XlWqNq9eePNVHpKAZvGCSPY4JuFREK7fMOcTpXhXzjqEVHMQDJ45hASjR6RMGgxP+q/XU+FfNf0cUo0Bajx/sw0CuzQYKdi8e4ggAAAABJRU5ErkJggg==">
</span></a> </div>
<div class="CvalNational">
<span style="color:#fff;font-weight:bold;">
National
</span>
</div>
<br>
</div>
</div>
JSfiddle link :
http://jsfiddle.net/8nbyc9m7/
Output without zoom :
if i zoom to 110% or 150% or 60% zooming it gives different output. that means last section is not aligned properly.
with zoom:
how to maintain the same output for all levels of zooming in all browsers.

Setting the container to have a width equals to the parent container does the trick for me
http://jsfiddle.net/kursion/8nbyc9m7/2/
Btw... you should probably concider doing a simple table ?
.CorpPerformance {
padding-left: 5px; <----------- changed
display: table;
border: 2px solid gray;
border-radius: 5px;
vertical-align: middle;
line-height: 30px;
width: 340px; <----------- changed
}
.CorpPerformance .DashboardTitle {
width: 80px; <----------- changed
}
.CorpPerformance .DashboardScore {
width: 40px; <----------- changed
}
.CorpPerformance .DashboardIcon {
width: 100px; <----------- changed
}
.CorpPerformance .CvalNational {
width: 119px; <----------- changed
text-align: center;
border-left: 1px dotted black;
background-color: gray;
}
80px + 40px + 100px + 119px + 1px(border) = 340px
And I removed the padding
.CorpPerformance .row > div {}
Edit: with a table... it's much more easier and zoom works ! Check the link in my comment

http://jsfiddle.net/victor_007/8nbyc9m7/3/
* {
box-sizing:border-box;
}
use box-sizing:border-box; which gives border and padding from inside and set the width exactly which you want

Here is your solution.
What I did is to correct your table and remove the width of the last cell so that it can be flexible. I have used table and tr and td instead of div as it will make your css lighter.
If you can't or don't want to change your div for table, tr and td, you can always add the following css on your div: display: table; to replace table, display: table-row; to replace tr, and display: table-cell; to replace td. The result will be the same.
.CorpPerformance {
border: 2px solid gray;
border-radius: 5px;
vertical-align: middle; /* it's defined for the whole table so you don't need to write it again */
line-height: 30px;
max-width: 343px;
border-spacing: 0; /* important for Chrome browser that add spacing */
}
img {
max-width: 100%;
vertical-align: middle;
border: 0;
}
.CorpPerformance > td {
padding: 0 5px 3px; /* I've just simplified the writing */
}
.CorpPerformance .DashboardTitle {
width: 110px;
}
.CorpPerformance .DashboardScore {
width: 25px;
}
.CorpPerformance .DashboardIcon {
width: 75px;
}
.CorpPerformance .CvalNational { /* no width anymore */
text-align: center;
border-left: 2px dotted black;
background-color: gray;
color: #fff; /* I've remove your span to put the css here, if you can do this it's best to keep html free of css */
font-weight: bold;
}
<table class="CorpPerformance">
<tr>
<td class="DashboardTitle">3 Month</td>
<td class="DashboardScore" style="font-weight:bold"> <a class="redirectLink" data-criteria-corporatesummarycategory="none" data-criteria-corporatesummaryexpand="0" data-criteria-customerpay="" data-criteria-expressservice="" data-criteria-maintenanceplan="" data-criteria-modelname="" data-criteria-rspenddate=""
data-criteria-rspstartdate="" data-criteria-warrantypay="" data-criteria-yearmodel="" data-criteria-department="Sales" data-criteria-reportperiod="[Collection Date].[Calendar].[Calendar Month].&[October 2014]" data-criteria-summaryperiod="3MONTH"
href="/Corporate/OFSSurveySummary">950</a>
</td>
<td class="DashboardIcon">
<a class="bootstrap-modal" data-criteria-chartcustomerpay="" data-criteria-chartexpressservice="" data-criteria-chartmaintenanceplan="" data-criteria-chartmodelname="" data-criteria-chartmodelyear="" data-criteria-chartwarrantypay="" data-criteria-chartdepartment="SALES"
data-criteria-chartmeasurename="Response Default Computation" data-criteria-chartmeasuretype="score" data-criteria-chartorganization="" data-criteria-chartpagetitle="NSSI Trend" data-criteria-chartreportperiod="[Collection Date].[Calendar].[Calendar Month].&[October 2014]"
data-criteria-chartsummaryperiod="3MONTH" data-criteria-charttitle="NSSI" data-criteria-chartwheretuple="[Questionnaire].[Questionnaire].[Question].&[OFSP]&[OFSP13011]" href="/Trend" modal-no-resize="True" upper="NSSI Trend"><span>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAAAZCAYAAACM9limAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHxSURBVFhH7Zg9SEJRFMcdW4QmcRI3xclNcYiGBocGB4dqMQTXdHdoFRqsoCAtJEiMKCpCHkHkECFJUNQgNqgEIQ19DIFBw8n/8SkUPft66n31fnBArnLh/O69556roQHp8WEYSOctuhgFhBdTLN5RLndN2WxZHukNQoopFGrk9W6S1Zogu32FhofXyeFI0cBAnHy+HUqlLunh4Vn+dWfq9RcWG4+f0sjIBnk8aZ5vcHC+kfgMz/URQolBspHIIdlsyxSLnVCl8ih/0wRJbm9f0eSkREbjHJlMC5wkYmIiS4GAxEJbY2bzIsvEZ8w7O3vKkhCfiRVGDFYOuwMr+1Vqtad2oonEOU1NHZAkldtj78V+h76LyedvWIjfv8uJikLfxGA1x8b2yO1O8+qKRs/FYFeMjm5xHclkivKoePRMTKuw4qaZnj7mQioyPRETDjeFoLCKLqRF18XgGh0f3/ty3yEKXRODnYGeQqmBEp2uiMHuQIeKnkKrqC6mVLqnoaGMpqUAVcXg+rVYlrht1zqqiMHRwfsFDZvWiqwSvxaTTF5wS6/VIqvEj8Wcnd3yq9XlWqNq9eePNVHpKAZvGCSPY4JuFREK7fMOcTpXhXzjqEVHMQDJ45hASjR6RMGgxP+q/XU+FfNf0cUo0Bajx/sw0CuzQYKdi8e4ggAAAABJRU5ErkJggg==" /></span></a>
</td>
<td class="CvalNational">Test National</td>
</tr>
</table>

Related

How to remove horizontal scroll bar with remaining of all elements into the page?

I am begginer in web-developing. Nevertheless I hope for aid.
I have one layout that has to be performed as webpage by me. It has header, footer, main. There are one static image in main, one menu and content part in main. All elements situates in correct position if the user does not change the scale in own browser. There's one requirement: footer, header and menu must be painted with some colors, but all content of them must contain in rectangles width of which is 1000px. And don't forget about padding-left and padding-right 10px. If the scale is increased there's horizontal scrollbar and some elements occur in right side.
My requirements:
all components must fit in the first 100% of width. There must not be any need to scroll horizontally.
this vertical scrollbar must disappear
body
{
font-family: PT Sans;
font-size: 14px;
line-height: 22px;
color: grey;
max-width: 100%;/*
overflow-x: hidden;*/
}
#correct_width_header_footer
{
background-color: #D3D3D3;
width: 100%;
clear: left;
}
#internal_width
{
width: 1000px;
margin: auto;
padding-right: 10px;
padding-left: 10px;
}
.header_sect
{
padding-bottom: 65px;
padding-top: 65px;
box-sizing: inherit;
}
#Left_header
{
height: 100px;
}
.phones
{
text-align: right;
font-size: 2em;
}
.menu_width
{
width: 100%;
background-color: grey;
}
.menu
{
color: white;
font-size: 20px;
text-align: center;
padding-bottom: 15px;
padding-top: 15px;
}
.menu a
{
text-decoration: none;
cursor: pointer;
}
.slider
{
width: 100%;
text-align: center;
margin-bottom: 30px;
}
.NewsBlock
{
width: 350px;
color: white;
background-color: grey;
padding-left: 35px;
padding-top: 20px;
padding-bottom: 100px;
margin-right: 60px;
float: left;
}
.article_right
{
width: 510px;/*
border: 1px solid;*/
float: left;
}
.height_lowerSect
{
/*display: inline-block;*/
/*margin-bottom: 700px;*/
}
.footer_sect
{
/*background-color: black;*/
position: relative;
}
#left_footer
{
float: left;
}
#left_footer li
{
list-style-type: none;
}
footer
{
background-color: grey;
width: 100%;
height: 160px;/*
margin-top: 65px;*/
}
.Underline li
{
text-decoration: underline;
}
.Underline
{
/*margin: auto;*/
/*display: block;
margin-left: auto;
margin-right: auto;*/
position: absolute;
left: 350px;
}
.Last
{
position: absolute;
right: 0%;
top: 15px;
}
<body>
<header id="correct_width_header_footer">
<section id="internal_width" class="header_sect">
<img src="logo.png" alt="logo" title="логтотип компании" id="Left_header" style="float: left;">
<section class="phones">
<br>+7(499)777-77-77</br>
<br>+7(499)777-77-77</br>
</section>
</section>
</header>
<main>
<section class="menu_width">
<div id="internal_width" class="menu">
<a>Главная</a> |
<a>Каталог</a> |
<a>Доставка и оплата</a> |
<a>Прайс-лист</a> |
<a>Контакты</a>
</div>
</section>
<img src="slider.jpg" class="slider" alt="slider">
<section class="height_lowerSect" id="internal_width">
<div class="NewsBlock">
<h1>Новости</h1>
<div>
<p>14 сентября 2013 г.
<br>Редизайн веб-сайта архитектурного бюро.
</div>
<div>
<p>14 сентября 2013 г.
<br>Раскрутка интернет-магазина декоративных стикеров и виниловых наклеек.
</div>
<div>
<p>14 сентября 2013 г.
<br>SEO-продвижение сайта поставщика дизельных генераторов.
</div>
<div>
<p>14 сентября 2013 г.
<br>Поисковое продвижение веб-сайта поставщика гидрооборудывания.
</div>
</div>
<section class="article_right">
<h1>Компания "Пиксель-Плюс"</h1>
<p>
Найстарішим з них є перший варіант. До початку вестернізації Японії у середині 19 століття ним позначали будь-який одяг. Ще у 16 столітті португальські місіонери-єзуїти повідомляли у звітах до Європи, що японці називають одяг словом «кімоно» (Kimono). Ця назва перекочувала у більшість іноземних мов, і в українську зокрема. Хоча у домодерній Японії «кімоно» було аналогом універсального поняття «одяг», у Європі та Америці воно стало асоціюватися саме з японським вбранням.
</p>
<p>
Наприкінці 19 століття у Японії збільшилась кількість тих, хто заходився носити західний стрій. Відмінність західного і японського костюму змушувала японців виокремити останній з загального поняття «кімоно». Виник неологізм для позначення традиційного одягу — «вафуку»[3] . До кінця Другої світової війни це слово стало основним для означення японського вбрання. Однак у післявоєнні часи, під впливом американського «розуміння» японської дійсності, універсальний термін «кімоно» почали застосовувати як один з синонімів «вафуку».
</p>
<p>
Відповідно, у сучасній японській мові «кімоно» отримало два значення. У широкому розумінні — це загальний термін для окреслення будь-якого одягу, а вузькому — різновид вафуку.
</p>
</section>
</section>
</main>
<footer id="correct_width_header_footer">
<section id="internal_width" class="footer_sect">
<div id="left_footer">
<ul>
<li>2012-2013 ЗАО "Комания"</li>
<li>info#name.ru</li>
</ul>
</div>
<div id="left_footer" class="Underline">
<ul>
<li>Главная</li>
<li>Каталог</li>
<li>Доставка и оплата</li>
<li>Прайс-лист</li>
<li>Контакты</li>
</ul>
</div>
<div id="left_footer" class="Last">
<u>Разработка сайта</u> -
<br> компания "Пиксель-Плюс"
</div>
</section>
</footer>
</body>
Adding CSS media queries would really help in your case. I would create a media query where your 1000px width's will be set to 100% if the resolution becomes to small. Here's a quick example on how to approach it:
/* Screens that are less then 1020px wide */
#media screen and (max-width: 1020px) {
#internal_width {
width: 100%;
}
}
I think you also need to lose some of the other hardcode widths and make them percentage based or give them an automatic width by using flexbox in combination with flex-grow. This would make them smaller when the screen width is smaller. But it will keep the aspect ratio of your content. I would also remove the floats in your code. For example if you want to have more flexibility in the main content you can do it like this:
#internal_width {
display: flex;
width: 1000px;
margin: auto;
padding-right: 10px;
padding-left: 10px;
}
.NewsBlock {
width: 350px;
color: white;
background-color: grey;
padding: 20px 0 100px 35px;
margin-right: 60px;
}
.article_right {
flex-grow: 1;
}
It set's the .NewsBlock content to 350px and the .article_right element next to it will just take up the space that it can have (until the combined value reaches 1000px). You can also apply this approach to your other elements as well.

HTML elements - of distinct types, but sharing the same class name - behaving strangely

So I'm building a website, which features several pages describing (fantasy) people and places. To that end, several categories of page have a profilebox which include stuff like a heading, an image and a table with some summary data.
The HTML for such a box looks like this:
<profilebox class="red">
<p><i>His Majesty</i><br><span class="big-and-strong">The King</span>
</p>
<figure class="pbox"><img class="pbox" src="../images/armsroyal.svg">
</figure>
<table class="pbox">
<tr>
<td>Surname</td>
<td>N/A</td>
</tr>
<tr>
<td>Forename</td>
<td>N/A</td>
</tr>
<tr>
<td>Rank</td>
<td>King</td>
</tr>
<tr>
<td>Addressed As</td>
<td>‘‘Your Majesty’’</td>
</tr>
</table>
</profilebox>
Whereas the CSS looks like this:
profilebox {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 1em;
margin-right: 0em;
width: 400px;
float: right;
text-align: center;
padding: 1em;
border-color: black;
border-style: solid;
border-width: 0px 0px 0px 5px;
}
table {
border-collapse: collapse;
width: 600px;
}
.mini {
width: 400px;
}
.maxi {
width: 100%;
}
.pbox {
width: 100%;
}
img {
margin: 1em;
}
.pbox {
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
}
figure.pbox {
width: 100%;
}
Now the pbox class of table has width set to 100%, so the table in the profile box should fill up its parent element, right? (I can feel a "Wrong!" coming on.) However, this is what the page actually looks like in Chromium:
Table too narrow
If I replace <table class="pbox"> with <table class="maxi">, I get the desired result:
Table just right
But the maxi and pbox classes of table are identical! Any idea what's going on here?
I had assumed - incorrectly - that if you put something like:
CSS
element1 {
property-a: setting1;
}
.class-name {
property-b: setting2;
}
element2 {
property-c: setting3;
}
.class-name {
property-d: setting4;
}
HTML
<element2 class="class-name"/>
Then element2 will have properties:
property-c: setting3;
property-d: setting4;
In fact, all definitions of .class-name will be applied, so element2 will have properties:
property-b: setting2;
property-c: setting3;
property-d: setting4;
If we amend the CSS as follows:
element1 {
property-a: setting1;
}
element1.class-name {
property-b: setting2;
}
element2 {
property-c: setting3;
}
element2.class-name {
property-d: setting4;
}
Then everything works!

CSS: Hover adds unwanted extra white space

I am simply trying to create a hover, so it hover over a entire section as seen below:
However, every time i hover over my products.
This happens instead
It adds extra white space to the section below and doesn't cover the section properly.
I have tried..
Changing the line height
Adding a new section/div
padding 0, margin 0
div#cat{
/*line-height: 30%;
height: 50px;*/
width: 61%;
margin-left: 39%;
height: 15px;
line-height: 50%
}
/*product area rollover/hover*/
div#cat:hover{
background-color: #e86065;
opacity: 0.5;
filter: Alpha(opacity=50);
background-position: 100% 100%;
height: 80%;
}
<div id='cat'>
<table>
<tr>
<td class='full'>
<a name='foodcat$iii' id='prods_nme'>$prod_name</a>
<td>
</td>
<p id='prods_desc'>$prod_desc</p>
</td>
<td class='price'>
<p id='prods_price'>£$prod_price</p>
</td>
<td class='add'>
<a href='Shopping_cart.php?add_item=$prod_id'>+</a>
</td>
</tr>
</table>
</div>
My code is actually a string, which loop information out of a database.
echo("<div id='cat$i' class='cat'>");
echo("<table>");
echo("<tr>");
echo("<td class='full'>");
echo("<a name='foodcat$iii' id='prods_nme'>$prod_name</a>");
echo("<td>");
echo("</td>");
echo("<p id='prods_desc'>$prod_desc</p>");
echo("</td>");
echo("<td class='price'>");
echo("<p id='prods_price'>£$prod_price</p>");
echo("</td>");
echo("<td class='add'>");
echo("<a href='Shopping_cart.php?add_item=$prod_id'>+</a>");
echo("</td>");
echo("</tr>");
echo("</table>");
echo("<br>");
echo("<br>");
echo("<hr id='hr'>");
echo("</div>");
echo("</div>");
echo("</div>");
echo("<br>");
echo("<br>");
$i++;
Your CSS is adding extra height when it changes to hover state. Make sure when you're adding hover styles that you only change the properties you want to - in this case, you don't want to change the height.
You want something like this:
div#cat{
width: 61%;
margin-left: 39%;
height: 15px;
line-height: 50%
}
/*product area rollover/hover*/
div#cat:hover{
background-color: #e86065;
opacity: 0.5;
filter: Alpha(opacity=50);
background-position: 100% 100%;
width: 61%;
margin-left: 39%;
height: 15px;
line-height: 50%
}
ArtOfCode has the correct solution for your problem.
However, it is not a good idea to use tables for formatting. You can see the table padding (which I have done all the right things to eliminate) when the cells are given borders. Tables bring with them a number of formatting problems.
I suggest that you use DIVs instead, and learn the three or four things needed to use float:left and/or flexbox.
table{border-collapse:collapse;}
td{border:1px solid #ccc;padding:0;}
div#cat {
/*line-height: 30%;
height: 50px;*/
width: 61%;
margin-left: 39%;
height: 15px;
line-height: 50%
}
/*product area rollover/hover*/
div#cat:hover {
background-color: #e86065;
opacity: 0.5;
filter: Alpha(opacity=50);
background-position: 100% 100%;
height: 80%;
}
<div id='cat'>
<table>
<tr>
<td class='full'>
<a name='foodcat$iii' id='prods_nme'>$prod_name</a>
<p id='prods_desc'>$prod_desc</p>
</td>
<td class='price'>
<p id='prods_price'>£$prod_price</p>
</td>
<td class='add'>
<a href='Shopping_cart.php?add_item=$prod_id'>+</a>
</td>
</tr>
</table>
</div>

div with float right breaking children

I have been looking everywhere for help on this issue with Css layout width I have been running into.
Whenever I float a div to the right its width won't automatically adjust to the total width of its children. I have observed this effect on all common browsers (Firefox, Chrome and IE11/Edge). What happens is that the last child will just be displayed bellow all the others which is what I do not want.
Here is the css and html I have been using.
https://jsfiddle.net/xqpf9s95/2/
*
<div id="header-container">
<div id="header-top-container">
<div id="header-logo">
<a href="/GlobalImagens/pages/imagens.xhtml?categoria=ultima-hora">
<img src="../resources/images/logo_globalimagens.jpg" alt="Global Imagens"></a>
</div>
<div class="header-top-right-corner">
<form id="language" name="language" method="post" action="/GlobalImagens/pages/imagens.xhtml" enctype="application/x-www-form-urlencoded">
<input name="language" value="language" type="hidden">
<div id="newsletter" class="newsletter">
Subscrever Newsletter
</div>
<div style="float: right; padding-left: 6%;">
<script type="text/javascript" src="/GlobalImagens/javax.faces.resource/jsf.js.xhtml?ln=javax.faces&stage=Development"></script>
<a href="#" style="text-decoration:none; " onclick="mojarra.jsfcljs(document.getElementById('language'),{'language:j_idt31':'language:j_idt31','localeCode':'en'},'');return false">
<img src="../resources/images/flag_uk.jpg" border="0"></a>
</div>
<div style="float: right;">
<a href="#" style="text-decoration:none;" onclick="mojarra.jsfcljs(document.getElementById('language'),{'language:j_idt35':'language:j_idt35','localeCode':'pt'},'');return false">
<img src="../resources/images/flag_pt.jpg" border="0"></a>
</div>
<input name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="215900126811062761:3093351618596041247" autocomplete="off" type="hidden">
</form>
</div>
<div id="admin-container">
<div>
<span class="admin-menu1" style="padding-left: 1.5%;">Iniciar Sessão
</span>
<span class="dotted-separator"></span>
<span style="padding-left: 1.5%;">Registo
</span>
<span class="admin-menu3"><a href="/GlobalImagens/pages/entrar.xhtml">
<img src="../resources/images/bt_minhaconta.jpg" title="A Minha conta" alt="A Minha conta"></a>
</span>
<span class="dotted-separator"></span>
<span class="admin-menu4"><a href="/GlobalImagens/pages/entrar.xhtml">
<img src="../resources/images/bt_carrinho.jpg" title="Meu carrinho" alt="Meu carrinho"></a>
</span>
</div>
<div>
<div align="right">
<span style="color: #83266f; padding-right: 5px;">Não pode adquirir imagens</span>(detalhes)
</div>
</div>
</div>
</div>
/*tables header*/
.admin-menu1 {
padding-right: 1.5%;
}
.dotted-separator {
border: none;
border-left: 1px dotted #83256f;
color: #fff;
/* background-color:#dadada;
height:17px;
width:0%;
margin: 0%; */
}
.admin-menu2 {
padding-left: 10px;
background: url(../images/background_dot.jpg) no-repeat right;
}
.admin-menu-logged-in-3 {
padding-left: 1.5%;
}
.admin-menu3 {
/* width: 75px; */
}
.admin-menu4 {
/* width: 28px; */
}
/*******************************HEADER*******************************/
#header-container {
/* height: 180px; */
/* float: left; */
}
#header-top-container {
/* width: 983px; */
/* height: 100px; */
/* float: left; */
}
#header-logo {
padding-top: 1%;
float: left;
}
#header-logo img {
border: none;
border-style: none;
}
.newsletter {
float: left;
padding-top: 1%;
}
.header-top-right-corner {
float: right;
padding-top: 1%;
width: 11%;
}
#admin-container {
padding-top: 1%;
font-size: 10px;
clear: right;
float: right;
box-sizing: border-box;
}
#admin-container a {
text-decoration: none;
color: #493641;
}
#admin-container a:hover {
text-decoration: underline;
}
*
And my issue is with the div "#admin-container".
How do I fix this so as to make that div auto adjust to the correct width and display without breaking its children elements?
Cheers and thank you.
EDIT: I have editted the code as asked by #Dzijeus. As I have commented, the images don't matter for the issue. My issue is with why the width won't auto adjust on the '#admin-container' to fit all its children.
Thanks for updating the code, it was better, but still far from a minimum verifiable example. A minimum example is when you strip as much as you can from the code while still reproducing the problem.
In your case, if you had done the exercise, you would probably have come to something like this:
<div id="admin-container">
<span class="admin-menu1">Iniciar Sessão</span>
<span>Registo</span>
<span>A Minha conta</span>
<span>Meu carrinho</span>
</div>
.admin-menu1 {
padding-right: 1.5%;
}
#admin-container {
clear: right;
float: right;
}
And you would immediately have seen the interest of doing this, AND solved the problem. Because from here, it is easy to notice that the problem is coming from using a relative padding. Switch to for example padding-right: 2px, and the display is now as you expected it.
As a general rule, padding and margin does not apply to inline elements such as span. To apply padding or margin you should use display: block or display: inline-block

CSS zoom and div alignment inside a table cell

I have the following content:
It is a table, with one row and three cells, two blue cells, and the middle cell, and in the middle cell I have a div, for now it looks good.
But if I put the zoom property in the div (zoom: 0.8) I get an extra space in IE11, as if the div was still the same size, like this:
In chrome, the table just adjusts to the div size, but not in IE, is there anyway I can achieve this?
This is the fiddle of the example:
http://jsfiddle.net/Z3wbN/3/
HTML:
<table class="container">
<tr>
<td class="border">
</td>
<td>
<div class="content">
This is a test
</div>
</td>
<td class="border">
</td>
</tr>
CSS:
.container {
background-color: #ddd;
}
.border {
background-color: blue;
width:10px;
}
.content {
margin: auto;
width: 500px;
border: 2px solid yellow;
zoom: 0.8;
}
One possible solution, although I don't know if you'll like it, could be this one: http://jsfiddle.net/Z3wbN/14/
On that solution:
A couple of classes/ids are added to the tags;
The width is assigned to the middle cell instead of to the div inside that cell;
if it's an IE browser, the div width is adjusted to 125% (100% / 0.8 that is the zoom).
The way of detecting the browser is JavaScript but you could try any that you want (I got it from Detect IE version (prior to v9) in JavaScript):
// if it's an IE browser then update the class to "container ie"
if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
document.getElementById("container").className = "container ie";
}
Then the CSS is adjusted as specified in the list above:
td.middle {
width:500px;
}
.content {
margin: auto;
border: 2px solid yellow;
zoom: 0.8;
}
.ie .content {
width:125%;
}
This solution displays a "similar" result on IE and Chrome/Firefox.
You need to use display:table-cell; to class .content
Here is the updated fiddle:
.container {
background-color: #ddd;
}
.border {
background-color: blue;
width: 10px;
}
.content {
margin: auto;
width: 500px;
border: 2px solid yellow;
zoom: 0.8;
display: table-cell;
}
zoom: 0.5;
<table class="container">
<tr>
<td class="border">
</td>
<td align="center">
<div class="content">
This is a test
</div>
</td>
<td class="border">
</td>
</tr>
</table>
All you need to do is to apply zoom to .container too :
.container {
zoom: 0.8
}
Here's the JSFiddle: http://jsfiddle.net/Z3wbN/12/