Currently my parent div is showing up as a dimensionless div (0 by 0 px). I am trying to have a flexible parent div thats size is not explicitly mentioned but rather adaps to the size of its content. Here is what I have so far thats producing a 0px by 0px parent. Hope someone can give me a solution.
HTML:
<div class="thumbnailDeal">
<div class="thumbnailImage">
<div class="thumbnailDescription">
<span class="thumbnailTitle">3 Maki Orders</span>
<div class="thumbnailPrices"><span class="thumbnailOriginal">$25</span> $<span class="thumbnailActual">15</span></div>
<br>
<span class="thumbnailRestaurant">New Generation Sushi</span><br>
<span class="thumbnailLocation">11 St Joseph st.</span>
</div>
</div>
</div>
<div class="thumbnailDeal">
<div class="thumbnailImage">
<div class="thumbnailDescription">
<span class="thumbnailTitle">3 Maki Orders</span>
<div class="thumbnailPrices"><span class="thumbnailOriginal">$25</span> $<span class="thumbnailActual">15</span></div>
<br>
<span class="thumbnailRestaurant">New Generation Sushi</span><br>
<span class="thumbnailLocation">11 St Joseph st.</span>
</div>
</div>
</div>
CSS:
.thumbnailDeal{
display: inline-block;
margin:1%;
}
.thumbnailImage{
width:360px;
height:315px;
background-size: cover;
background-image: url(../assets/5.jpeg);
background-position: center center;
background-repeat: no-repeat;
position:absolute;
}
.thumbnailDescription{
height:28%;
width:100%;
background: rgba(0, 0, 0, 0.75);
position:absolute;
bottom:0;
padding:10px;
}
.thumbnailTitle{
color:white;
font-size:17px;
}
.thumbnailRestaurant{
color:#FD8B2B;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size:14px;
}
.thumbnailLocation{
color:#9E9E97;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size:14px;
position:absolute;
left:0px;
bottom:0px;
padding-left:10px;
}
.thumbnailPrices{
font-size:14px;
color:white;
position:absolute;
right:0px;
bottom:-13px;
box-sizing: border-box;
}
.thumbnailOriginal{
text-decoration: line-through;
color:#9E9E97
}
.thumbnailActual{
font-size:50px;
color:white;
position:relative;
right:10px;
}
When you use position: absolute elements get out of the flow and the parent won't have height/width from his childs anymore.
You have to find another way to position your elements if you want to have a proper height/width to the parent :)
Related
<div id='mdnew'>
<div class=' gblue mdtitle'>NEW TAG</div>
<input id='inpnew' type='text' autocomplete='off' maxlength=25 placeholder='NEW TAG'>
<div class='gblue leftcancel'>CANCEL</div>
<div class='gblue rightok' id='newok'>OK</div>
<div class='clear'></div>
</div>
when input has focus (i.e. pointer is inside) and mouse is over cancel button - input loses its left margin !
complete code is here
Wrap your input with div and it will work.
* {
margin:0;
padding:0;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
#mdnew {
position:fixed;
z-index:2;
width:300px;
left:calc(50% - 150px);
top:63px;
background: red;
border-radius:5px;
overflow:hidden;
}
#inpnew {
display:block;
width:calc(100% - 28px);
margin:14px auto;
line-height:21px;
outline:none;
border:1px solid #999;
border-radius:5px;
padding:0 7px;
}
.leftcancel {
float:left;
width:50%;
line-height:23px;
cursor:pointer;
text-align:center;
}
.rightok {
float:right;
width:50%;
line-height:23px;
cursor:pointer;
text-align:center;
}
.leftcancel:hover, .rightok:hover {
opacity:0.8;
}
.gblue {
background: -webkit-linear-gradient(to top, #003b61, #0099cc);
background: linear-gradient(to top, #003b61, #0099cc);
color:white;
letter-spacing:0.5px;
}
.mdtitle {
line-height:23px;
text-align:center;
letter-spacing:0.5px;
}
<div id="mdnew">
<div class=" gblue mdtitle">NEW TAG</div>
<div>
<input id="inpnew" type="text" autocomplete="off" maxlength="25" placeholder="NEW TAG" >
</div>
<div class="gblue leftcancel">CANCEL</div>
<div class="gblue rightok" id="newok">OK</div>
<div class="clear"></div>
</div>
Here is the Updated Fiddle..
Its because opacity of .leftcancel,rightok on hover, its effecting to the sibling
remove that part and test
.leftcancel:hover, .rightok:hover{
//opacity:0.8;
}
fiddle
Update :
To make it work with opacity, add position and z-index to .leftcancel and .rightok
The opacity you're setting on .leftcancel and .rightok is creating a new stacking context, and stacking contexts affect z-indexes. Since you didn't specify z-indexes manually, they're being auto assigned, and .leftcancel and .rightok has a higher value than #inpnew because it comes later in the markup.
Reference : W3C Color Module
If an element with opacity less than 1 is not positioned, implementations must paint the layer it creates, within its parent stacking context, at the same stacking order that would be used if it were a positioned element with ‘z-index: 0’ and ‘opacity: 1’.
*{
margin:0;
padding:0;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
#mdnew{
position:fixed;
z-index:2;
width:300px;
left:calc(50% - 150px);
top:63px;
background: red;
border-radius:5px;
overflow:hidden;
}
#inpnew{
display:block;
width:calc(100% - 28px);
margin:14px auto;
line-height:21px;
outline:none;
border:1px solid #999;
border-radius:5px;
padding:0 7px;
}
.leftcancel{
position:relative;
z-index:5;
float:left;
width:50%;
line-height:23px;
cursor:pointer;
text-align:center;
}
.rightok{
position:relative;
z-index:5;
float:right;
width:50%;
line-height:23px;
cursor:pointer;
text-align:center;
}
.leftcancel:hover, .rightok:hover{
opacity:0.8;
}
.gblue{
background: -webkit-linear-gradient(to top, #003b61, #0099cc);
background: linear-gradient(to top, #003b61, #0099cc);
color:white;
letter-spacing:0.5px;
}
.mdtitle{
line-height:23px;
text-align:center;
letter-spacing:0.5px;
}
<div id='mdnew'>
<div class=' gblue mdtitle'>NEW TAG</div>
<input id='inpnew' type='text' autocomplete='off' maxlength=25 placeholder='NEW TAG'>
<div class='gblue leftcancel'>CANCEL</div>
<div class='gblue rightok' id='newok'>OK</div>
<div class='clear'></div>
</div>
Updated fiddle is : https://jsfiddle.net/5qperdzb/16/
If you're calculating input's width as 100% - 28px then it's safe to just use 14px for margin-left and margin-right:
#inpnew {
margin: 14px;
}
This has been bothering me for a while. I have currently vertically align a border contain the word "Facebook" to an image but, vertical align isn't completely centering the word with the image.
Update 1: I am using Width 100% and Line-Height 100%. This is close to how I want it but not quite. https://gyazo.com/f67cff590476c9e11601172b5b1dafd5 I want the border and the image to align. Here is my old code:
HTML
<div id="div06">
<img id="img01" src="https://www.facebook.com/images/fb_icon_325x325.png"/>
<span id="span01">Facebook</span>
</div>
CSS
#div06
{
margin-top:3%;
display:inline-block;
width:100%;
line-height:100%;
}
#img01{
width:10%;
vertical-align:middle;
}
#span01
{
border:3px solid blue;
padding: 35px;
margin: 25;
}
Here is my current edit:
#div06{
margin-top:3%;
width:100%;
line-height:100%;
}
#img01{
width:10%;
vertical-align:middle;
}
#span01{
border:3px solid #3b5998;
color:#000000;
font-family:arial, bold;
font-size: 30px;
padding: 35px;
margin: 25;
}
It is vertically aligned in the full version but visually it's not (https://gyazo.com/f67cff590476c9e11601172b5b1dafd5 In this screenshot, the text does center align but the order doesn't. How do I make the border align?). I want them to align. If it is visually vertical for you then this problem only exists with the full version. I think it might be the image but, I don't know. How Do I fix this?
Also if you need the full code I will provide it below.
Full Code
HTML
<head>
<!--
Assignment: Personal Website
Date: 10/4/16
Name: Bradley Elko
-->
<link rel="stylesheet" href="personalWeb1.css">
</head>
<body>
<div id="div01">
<h1 id="h101">Bradley's Website</h1>
</div>
<div id="div02">
<h3 id="h301">My Band</h3>
<h3 id="h302">My Handlers</h3>
<h3 id="h303">My Ideas</h3>
</div>
<div id="div03">
<div id="div04">
<h2 id="h201">Formal Unknown Cereal Killer</h2>
</div>
<div id="div05">
<p id="p01">Date: 10/05/2016 (Latest Update)
<blockquote>
Summary:
<br/>
<br/>
Formal Unknown Cereal Killer is a band I made on September 30th, 2016. I don't have anyone else in it, but I will keep trying to get more members. The band will be a metalcore band(a rock genre). I may implement other instruments into the band (such as a violin, flute, clarenet, or another unique instrument). If you want to keep up to date check us out. The links are down below.
</blockquote>
<div id="div06">
<img id="img01" src="https://www.facebook.com/images/fb_icon_325x325.png"/>
<span id="span01">Facebook</span>
</div>
<div id="div07">
<img id="img02" src="https://pbs.twimg.com/profile_images/767879603977191425/29zfZY6I.jpg"/>
</div>
</div>
</div>
</body>
CSS
a:link{
color:#1a0000;
border-right:2px solid;
border-left:2px solid;
padding:5;
}
a:visited{
color:#950f0f;
}
a:hover{
color:red;
}
a:focus{
color:#eeeedd;
}
#div01 {
position:fixed;
top:0px;
left:0px;
right:0px;
height:80px;
bottom:90%;
font-family:Arial, Helvetica, sans-serif;
font-size:25px;
background-color:#73778c;
color:#950f0f;
text-align:center;
border-top:3px solid #950f0f;
border-bottom:2px solid #950f0f;
padding-top:0;
display:inline-block;
}
#h101{
margin-top:10;
margin-bottom:10;
}
#div02{
position:fixed;
top:85px;
left:0px;
right:0px;
display:inline-block;
background-color:#73778c;
color:#950f0f;
border-bottom:2px solid #950f0f;
text-align:center;
padding-top:5;
padding-bottom:5;
font-family:verdana;
font-size:12px;
}
#h301{
display:inline;
}
#h302{
margin-left :20%;
margin-right:20%;
display:inline;
}
#h303{
display:inline;
}
#div03{
position:fixed;
padding-top:0;
top:114px;
left:0%;
right:0%;
bottom:0%;
background-color:#73778c;
color:#950f0f;
border-bottom:3px solid #950f0f;
}
#div04{
font-size:30;
text-align:center;
margin-top:-30;
}
#h201{
font-family:Times New Roman;
}
#div05{
margin-left:100;
margin-right:100;
margin-bottom:100;
margin-top:-30;
padding-top:10;
padding-bottom:10;
padding-left:30;
padding-right:20;
border:3px solid #950f0f;
background-color:#e0e0d1;
}
#div06{
margin-top:3%;
display:inline-block;
width:100%;
line-height:100%;
}
#div07{
margin-top:3%;
}
#img01{
width:10%;
vertical-align:middle;
}
#span01{
border:3px solid blue;
padding: 35px;
margin: 25;
}
#img02{
width:10%;
}
Also (If you get this far you don't have to answer this. I'm just curious), how do you get Fullscreen inspect elements? Whenever I use it, it takes up a portion of the page that displays the portion of the website, but I want it to display the Fullscreen results [(This has been answered)].
Trying using text-align:
#div06 {
margin-top:3%;
display:inline-block;
width:100%;
line-height:100%;
text-align: center;
}
And to make the chrome dev-tools full screen, press the 3 small dots close to the side (menu button), and beside 'Dock side' there is a button to 'pop out'. This will make a new window with which you can resize as much as you need.
My friend told me I should use a table and it worked! Here is the snippet of code:
HTML
<table>
<tr>
<div id="div06">
<th><img id="img01" src="https://www.facebook.com/images/fb_icon_325x325.png"/></th>
<th><span class="span01"><a class="a02" style="text-decoration:none" target="_blank" href="https://www.facebook.com/groups/247367778991930/">Our Facebook Band Group</a></span></th>
</div>
</tr>
</table>
CSS
#img01
{
width:100px;
height:100px;
vertical-align:middle;
}
span.span01
{
border:3px solid #ffffff;
color:#000000;
font-family:arial;
font-size: 16px;
padding:38.5px;
margin: 25;
}
I am making a CSS design for a SIM game I play, and a customer asked for 4 boxes, two large and in between them, two horizontally aligned boxes. They work fine, unless I try and add headers. The entire website is set up in a ridiculous amount of tables, basically coding from the 90s. All boxes I have made are div and aligned to meet up with the existing boxes on the page.
The main boxes are how I want the headers on all four boxes, separate and do not scroll. However, as you can see from this fiddle, nothing is aligning. When I try to put headers on the horizontal boxes, it really messes up the align. I am a fairly new coder, and would greatly appreciate some help.
div {
display: block;
color: #fff;
}
.topcontain{
width:500px;
height:300px;
}
.topleftbox {
width:240px;
height:300px;
overflow:auto;
float:left;
background:#505665;
color:#fff;
text-align:center;
display:block;
font-family: 'Snippet', sans-serif;
font-size: 12px!important;
margin: 5px;
opacity: .75;
}
.toprightbox {
width:240px;
height:300px;
overflow:auto;
float:right;
background:#505665;
color:#fff;
text-align:center;
display:block;
font-family: 'Snippet', sans-serif;
font-size: 12px!important;
margin: 5px;
opacity: .75;
}
.bottomcontain {
width:500px;
height:300px;
}
.header {
width:500px;
float:center;
background:#060e23;
color:#fff;
text-align:center;
display:block;
font-size: 14px;
border: 1px solid #030711;
opacity: 1.0;
}
.bottombox {
width:500px;
height:300px;
overflow:auto;
float:center;
background:#505665;
font-size: 12px;
color:#fff;
text-align:center;
display:block;
font-family: 'Snippet', sans-serif;
opacity: .75;
}
.credit {
width:500px;
float:center;
background:#060e23;
color:#fff;
text-align:center;
display:block;
font-size: 12px;
border: 1px solid #030711;
opacity: .85;
}
.top {
font-family: 'Snippet', sans-serif;
background : #060e23;
color : #fff;
font-size : 15px;
padding : 5px 15px;
font-weight : normal;
text-align : center;
border: 1px solid #030711;
opacity: .90;
}
Here is how it looks on the page I am coding:
example
Thank you again!
http://jsfiddle.net/6bEsE/6/
<div class="bottomcontain">
<div class="header">Lorem ipsum</div>
<div class="bottombox">
[TOP]
</div>
</div>
<div class="topcontain">
<div class="topleftbox">
<div class="top">Lorem ipsum</div>
<div>
[MIDDLE LEFT]
</div>
</div>
<div class="toprightbox">
<div class="top">Lorem ipsum</div>
<div>
[MIDDLE RIGHT]
</div>
</div>
</div>
<div class="bottomcontain">
<div class="header">Lorem ipsum</div>
<div class="bottombox">
[BOTTOM]
</div>
</div>
<div class="credit">Layout and CSS by Echo [#15480]</div>
I did a fast clean of your code (5 minutes)
But it is far from finishing it
First of all, you have bad closing of divs.
Second, you have fixed height for divs. A div with fixed width and height and more text than can fit in it will create scrolls.
before inserting all that text, try to fix the containers starting from the simple example i provided above. Also you may need to change a bit the html structure, to group those floating middle divs.
Demo Fiddle
In CSS
.clear{
clear:both;
}
In HTML
<div class="clear"> </div>
I have a div class with a background image set. It displays ok on pc browsers but it wont show the image on mobile browser(i have tried android and ios)
the html
<div class="wrapper">
<div class="headerdiv">
<?php include '../inc/header.php';?>
</div>
<div id="wherewhen">
<div id="when">
<span class="wherewhen">WHEN IS IT?</span><br />
<span class="wherewhentext">9TH/10TH FEBUARY 2014</span>
</div>
<div id="where">
<span class="wherewhen">WHERE IS IT?</span><br />
<span class="wherewhentext">HOLIDAY INN, MILTON KEYNES, ENGLAND</span>
</div>
<div id="what">
<span class="wherewhen">WHAT IS IT?</span>
</div>
<div id="info">
<span class="wherewhentext">
A BACK IN THE DAY STYLE CONVENTION
FOR DISENFRANCHISED ARTISTS AND TATTOO FANS FED UP
WITH TODAY'S COMMERCIAL CORPORATE EXPOS.
</span>
</div>
</div>
<div class="poster">
</div>
the css
html, body{
margin:0;
padding:0;
width:100%;
height:100%;
overflow:auto;
background:#000000;
}
.wrapper{
width:80em;
margin: 0 auto 0 auto;
background:#000000;
overflow:hidden;
}
.poster{
float:left;
margin:-900px 0 0 910px;
width:370px;
min-height:600px;
background:#ffffff url('../images/siteimages/background.png');
}
#wherewhen{
background:#392da3;
width:600px;
margin:20px 20px 0 295px;
text-shadow: 2px -2px #000000;
}
#where{
float:left;
text-align:center;
width:20em;
}
#when{
float:right;
text-align:center;
width:15em;
}
#what{
width:20em;
text-align:center;
margin:0 auto 0 auto;
}
#info{
width:30em;
margin:0 auto 0 auto;
}
Can anyone offer assistance here?
Thanks...
oki, #poster background could be in #wrapper with background-attachement:fixed.
Else from your code (#poster outside #wrapper )
#wrapper {
position:relative;
z-index:1;
/* your rules */
}
#poster {
position:fixed;
z-index:0;
top:0;
left:0;
/* your rules */
}
I have a little problem with CSS hover...I have two divs in the same class but I wanna hover only one.
I already tried but it is not working and if it's working it changes for each color.
<div class="container iphone">
<!-- First box -->
<div class="span3 iphone-box-left">
======> <div class="quoteLeft"> <====== :hover
<blockquote>
<p>
description here
</p>
</blockquote>
<p class="credit">
johny
</p>
</div>
</div>
<!-- First box end -->
<!-- Second box -->
<div class="span6">
<img src="images/iphone.png">
<!-- Start Logo -->
<div class="logo-second">
<h3>
==============================================================
So when i hover on qouteLeft i wanna change the color on icon
this icon i also have in logo
====> <i class="icon-cloud icon-large"></i> <=================
creative
</h3>
</div>
<!-- Logo end -->
</div>
<!-- Second box end -->
CSS
.iphone {
position: relative; margin:50px auto; background:url(../images/11.png);
}
.quoteLeft {
position:relative;
top:40px;
padding:15px 25px 20px;
margin:20px auto;
font:italic 26px/1.4 Georgia, serif;
color:#fff;
background:rgba(34, 34, 34, .5);
}
.quoteLeft:after {
content:"";
position:absolute;
top:100%;
left:100%;
margin-top:-4px;
background:url(../images/box-line.png) no-repeat;
width:150px; height:165px;
}
.quoteRight {
position:relative;
top:150px;
padding:15px 25px 20px;
margin:20px auto;
font:italic 26px/1.4 Georgia, serif;
color:#fff;
background:rgba(34, 34, 34, .5);
}
.quoteRight:after {
content:"";
position:absolute;
top:100%;
right:80%;
margin-top:-4px;
background:url(../images/box-line-2.png) no-repeat;
width:300px; height:165px;
}
.credit {
margin:1em 0 0;
font:14px/1.2 Arial, sans-serif;
}
.credit:before {
content:"— ";
}
blockquote, p {padding:0; margin:0;}
.logo-second { position:absolute; margin-top:-20%; margin-left:11%;}
.logo-second h3 { font-size:56px;}
.quoteLeft:hover {And....}
I prefer any ideas css or jquery
Thanks
I think this is what you are looking for:
HTML
<div class="main">
<div class="first">First</div>
<div class="second">Second</div>
</div>
CSS
.main .first:hover ~ .second {
background-color: #f00;
}
I also made a jsFiddle