I have a simple inner/outer div problem where it's probably easier to explain through pictures. Here is my issue:
The comment "This is a witty comment." is not breaking down underneath the other 2 labels. Here is my HTML:
<div class="commentOuter">
<div class="commentAuthor">someauthor</div>
<div class="commentDate">17 minutes ago</div>
<div class="commentText"><span>This is a witty comment.</span></div>
</div>
And here's the CSS:
.commentOuter
{
border-radius: 4px;
width: 100%;
height: 20px;
float: left;
background-color: black;
margin-top: 10px;
padding: 5px;
}
.commentAuthor
{
float: left;
font-size: smaller;
color: #68a5d9;
display: block;
height: 15px;
}
.commentDate
{
float: left;
font-size: smaller;
margin-left: 5px;
color: #AAA;
display: block;
height: 15px;
}
.commentText
{
display: block;
width: 100%;
}
I don't understand that when I highlight the element in the dev tools, the div is not showing to be underneath the labels, as seen in this pic:
Any help is much appreciated.
Because you floated the previous 2 elements. If you need to move it below. Use a clear:
.commentText
{
clear:both;
display: block;
width: 100%;
}
You also have to remove the specified height for the .outerComment element.
Just because it's not floated, doesn't mean it won't be next to other elements.
See more here: https://css-tricks.com/all-about-floats/
Related
I'm trying to put divs side by side, but it's not working. One is inline, and the next one is down a little bit and a little bit to the right.
My code:
.FifteenInfo {
display: inline;
margin-top: 50px;
height: auto;
padding-right: 75px;
float: left;
}
.FourtyInfo {
display: inline;
margin-top: 50px;
height: auto;
padding-right: 75px;
}
.SixtyInfo {
display: inline;
margin-top: 50px;
height: auto;
padding-right: 75px;
}
.Package {
padding-left:70px;
margin-top: 15px;
}
.monthlyPrice {
padding-left:55px;
font-size:52px;
font-weight: bold;
color: #277FD8;
}
.differentbandwidth {
margin-left: 30px;
display: inline;
text-align: center;
padding: 15px;
border-style: solid;
border-color: #277FD8;
border-width: 3px;
border-radius: 8px;
}
.border {
border-left: thick solid #277FD8;
display: inline;
float: right;
}
.FifteenSpecs {
display: inline;
float: right;
}
<div class="FifteenInfo">
<h1 class="Package">Cable 15</h1>
<h3 class="monthlyPrice">\$39.99</h3>
<h3 class="differentbandwidth">\$69.99 Unlimited</h3>
<div class="FifteenSpecs border">
<h1>Cable 156666666666666666666666</h1>
<h3>\$39.99</h3>
<h3>\$69.99 Unlimited</h3>
</div>
</div>
Here's my image of the issue:
I'm completely lost, I've tried inline, and inline-block display times and they don't work.
So then I watched a couple of YouTube videos to brush up on display properties but it didn't work.
You mentioned in your comment that you wanted to make .FifteenSpecs.border display next to (inline with) .FifteenInfo.
The main problem then is simply that you have your .FifteenSpecs div inside your .FifteenInfo one, and hence it is displaying inside .FifteenInfo. Simply move it outside, like so:
body, html {
min-width: 1000px;
}
.FifteenInfo {
display: inline-block;
height: auto;
background-color: green;
vertical-align: top;
}
.monthlyPrice {
font-size:52px;
font-weight: bold;
color: #277FD8;
}
.differentbandwidth {
text-align: center;
border-style: solid;
border-color: #277FD8;
border-width: 3px;
border-radius: 8px;
}
.FifteenSpecs {
display: inline-block;
background-color: red;
vertical-align: top;
}
<div class="FifteenInfo">
<h1 class="Package">Cable 15</h1>
<h3 class="monthlyPrice">\$39.99</h3>
<h3 class="differentbandwidth">\$69.99 Unlimited</h3>
</div>
<div class="FifteenSpecs border">
<h1>Cable 156666666666666666666666</h1>
<h3>\$39.99</h3>
<h3>\$69.99 Unlimited</h3>
</div>
Some other things I changed in your code:
Changed inline to inline-block so that it retains the box model
Removed all the padding, margin: this really cluttered it up
Removed floats: inline-block will already make it "float" left.
Added vertical-align: top to make the top of the divs line up (as opposed to the bottom)
I have two divisions next to each other with attribute display: inline-block;; if I increase the height of the second division, the position of the first goes down by the amount I increased the height by, for example - if I add a slogan under my name as seen in this fiddle http://jsfiddle.net/wyorLh6s/1/ the position of the icon/logo goes down.
It's probably really obvious, but it's been a long weekend and I could use a push in the right direction - cheers guys.
.top {
background: #2980b9;
padding: 20px;
padding-left: 200px;
padding-right: 200px;
}
.top .logo {
position: relative;
}
.top .logo .icon {
font-weight: bolder;
color: white;
}
.top .logo .icon {
display: inline-block;
width: 10px;
height: 10px;
padding: 25px;
padding-top: 5px;
padding-bottom: 45px;
border: 3px solid white;
text-align: center;
}
.top .logo .name {
display: inline-block;
color: white;
text-transform: uppercase;
}
<div class="top">
<div class="logo">
<div class="icon">JH</div>
<div class="name">
<div class="title">Jack Hardcastle</div>
<div class="slogan">Slogan Goes Here</div>
</div>
</div>
</div>
My aim is to have the name inline with the JH in the logo/bordered-text, with the slogan underneath that text, http://jsfiddle.net/wyorLh6s/1/ can be seen here if the slogan div is removed.
As elements are displayed inline, .icon is affecting .name's baseline (default vertical-align), so you can do the following to change this behaviour:
.name{ vertical-align: top; }
JSFiddle
I have been trying to align two elements, a h2 and a div side by side without having one of them colapse when the window changes to a smaller size. I've searched the web a bit but found nothing similar that would help and my solutions just wouldn't work so I though here there would be someone able to help me.
So I want it to be displayed like this at all times:
https://imagizer.imageshack.us/v2/912x135q90/631/ZYR7sc.png (Can't post images sorry!)
But when window size changes dispite the fact the div should adapt at some point it just breaks to next line:
https://imagizer.imageshack.us/v2/730x144q90/912/yRBpkc.png
Here is my code on this one:
HTML
<div id='pagetitle'>
<h2 id='subtitle'>Weapons</h2>
<div id='hline'></div>
</div>
CSS
#pagetitle { /* This div is for centering both of the elements. */
width: 90%;
margin: 0 auto;
display: block;
}
#subtitle {
display: inline-block;
color: #72c9b9;
font-size: 30px;
font-weight: 300;
text-align: center;
}
#hline {
display: inline-block;
background-color: #72c9b9;
width: 70%;
height: 1px;
position: relative;
bottom: 4px;
margin-left: 20px;
}
So this is it guys, any sugestions? Thanks in advance.
cs.almeida
Here's a way how to do it:
demo
<div id='pagetitle'>
<h2 id='subtitle'><span>Weapons</span></h2>
</div>
#pagetitle {
width: 90%;
margin: 0 auto;
display: block;
}
#subtitle {
border-bottom: #72c9b9 solid 2px;
height: 18px;
display: block;
color: #72c9b9;
font-size: 30px;
font-weight: 300;
}
#subtitle > span {
background-color: white;
padding: 10px 20px;
}
I know I could use float and put the image to the left, but how can I then have those numbers, the header, and those three columns?
HTML:
<div class="images">
<ul>
<li class="image"><img src="https://www.ofbizdemo.com/images/products/PC001/large.png" />
<p class="padding">Text Here</font>
</ul>
</div>
CSS:
.images ul li {
display: inline;
}
.image {
float: left; // float to the left
}
p.padding {
float: right;
padding-top: 0px;
padding-bottom: 0px;
padding-right: 500px;
padding-left: 150px;
}
I'm using that for my CSS, but my text does not get exactly aligned to the right hand side, and I'm unsure of how I can add those numbers that the picture shows.
Just as a starting point:
http://jsfiddle.net/wpQb9/1/
.col {
float: left;
padding: 0 20px;
width: 300px;
text-align: right;
position: relative;
}
.col:before {
position: absolute;
top: 20px;
left: 30px;
width: 40px;
height: 40px;
line-height: 40px;
text-align: center;
border-radius: 20px;
background: yellow;
display: block;
}
.col:nth-child(1):before {
content:"1";
}
.col:nth-child(2):before {
content:"2";
}
.col:nth-child(3):before {
content:"3";
}
p {
margin-left: 100px;
}
.col being one of columns, a div element.
But seriously now: there are thousands of way to do it. My example is lacking: background images, proper paddings/margins, fonts(?), width of columns themself. That much please do your best to figure out. Protip: use google.
use a separate DIV for each of the 3 columns. a class for the text header and another for the text and then a class for the circle. Border-radius to make it round and I think you can figure out the rest. Does that answer your question?
I have a panel. Which looks like this:
It's not best, but its a copy of things I have in a PSD. The problem is that when you check HTML <a> is before image display and it still make <a> as 0x0px, the problem is with all 3 images in that panel and I don't know how to fix it. Can somebody help me to make each <a> to be as big as that image and button are?
HTML:
<section class="panel">
<img src="images/right_banner.png">
<div class="panel_button"><span class="text">NAHLĂSIT CHEATERA</span></div>
<div class="panel_button"><span class="text">CW/TG REZERVACE</span></div>
</section>
CSS:
.panel {
width: 200px;
float: left;
margin-top: 13px;
}
.panel a {
width: 201px;
height: 200px;
display: inline-block;
}
.panel_button {
background-image: url("images/panel_blue_button.png");
background-repeat: repeat-x;
width: 198px;
height: 93px;
margin-top: 5px;
font-weight: 16px;
}
.panel_button span{
color: #ffffff;
text-align: center;
display: inline-block;
margin-top: 40px;
margin-left: 30px;
}
Live preview
The anchor element is currently an inline element. You could change it to either block or inline-block to achieve the desired results.
.panel > a {
display: block;
}