HTML text aligned strange - html

I experience some strange text alignment, can you give me a hint where the Problem is:
I was trying to create a speechbubble:
.round
{
margin-top: 5px;
border-radius:50%;
background-color:#3d5177;
width:50px;
height:50px;
float: left;
}
.number {
color: white;
padding: 8px 17px;
font-size: 30px;
font-weight: normal;
}
.faq_container {
overflow: hidden;
}
.talkbubble {
left: 80px;
position: relative;
width: 340px;
height: 100px;
padding: 0px;
background: #aaaaaa;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
.talkbubble:after {
content: '';
position: absolute;
border-style: solid;
border-width: 10px 13px 10px 0;
border-color: transparent #aaaaaa;
display: block;
width: 0;
z-index: 1;
left: -13px;
top: 22px;
}
.talkbubble_text {
display: block;
text-align: left;
padding: 10px;
}
http://jsfiddle.net/Lf4sr/
Thanks

The problem is with the <div class="round"> CSS. The width of the element is pushing the text over to the right.
Add this to the .round class:
.round {
top: 0;
left: 0;
position: absolute;
}
And add this to the .faq_container class:
.faq_container {
position: relative;
}
Demo
Note: You can remove float: left; from .round.

Correct CSS should be:
.talkbubble {
left: 30px; /* or Whatever you may want the distance from the circle to be */
position: relative;
width: 340px;
height: 100px;
padding: 10px;
background: #aaaaaa;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
float: left;
}
.talkbubble_text {
display: inline;
text-align: left;
/* padding: 10px; ( remove this )*/
}

try adding float:left to the .talkbubble container

You can try this:
Fiddle here
.talkbubble_text {
display: inline-block;
text-align: left;
padding: 10px;
line-height:16px;
}
Good Luck...:)

I think the issue is that your last line of text is not inline with the others. This is due to the way you are laying out your code. Your text is being pushed across by your round element, which is a set height. Any text after this is not being pushed across, a quick fix would be to add a margin on the bottom of the number circle.
.round
{
margin-top: 5px;
border-radius:50%;
background-color:#3d5177;
width:50px;
height:50px;
float: left;
margin-bottom : 50px;
}
http://jsfiddle.net/Lf4sr/4/
But would probably be better to restructure your code a little to stop this happening in the first place.

Change positions, add overflow:hidden to .talkbubble_text to prevent float left align. Fiddle.

Updated: http://jsfiddle.net/Bushwazi/Lf4sr/8/
There are a lot of things that could be cleaned up in this example. There is lots of extra html. But the core problem is that if you are using float for one part, you have to use it for both. So you need to add float:left or right to .talkbubble and remove the left value.
.talkbubble {
/* left: 80px; */
position: relative;
width: 340px;
height: 100px;
padding: 0px;
background: #aaaaaa;
float:left;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
I did a bunch of other stuff in the fiddle to simplify and eliminate extra html/css too. But the core problem was mixing positioning with float and choosing just one.

Related

What is wrong with my CSS alignment in my CODE

I am trying to get the Z to come in the middle of the cricle but I am not sure why its not coming in the middle. My code outputs this
<li class="avatar"><span class="profile-initials">Z</span></li>
This is the CSS I have on my application
.avatar {
vertical-align: middle;
width: 20px;
background-color: white;
height: 25px;
border-radius: 50%;
padding-left: 18px;
padding-bottom: 10px;
float: right;
margin: 10px;
}
.profile-initials {
margin-right: 2px;
}
It is hard to tell without looking at all of your code but the CSS could be much simpler using something like flexbox.
As for your code it seems your padding left and padding bottom are pushing it out of the frame and your and the border radius just makes it look like its outside of the circle.
Here is what I quickly came up with I hope it helps.
li {
background-color: #000;
color: #fff;
width: 300px;
height: 50px;
display: flex;
align-items: center;
}
.name {
flex-grow: 2;
padding-left: 18px;
}
.icon {
margin-right: 18px;
background-color: #fff;
padding: 10px;
color: #000;
border-radius: 50%;
}
<ul>
<li><span class="name">Veris Veritatis</span><span class="icon">Z</span></li>
</ul>

CSS is not applied on footer angularjs

I have been struggling with this for two days now, though it looks very simple.
As you see the footer i created in the picture here:
I have two problems:
I cannot seem to apply any css modifications on the footer inside the text ("Capgemini newcomer application")
I cannot add a line separating the rest of the page from the footer without intercepting the logo or applying a margin between the page content and the footer like shown in the next photo:
HTML code
<ion-footer-bar class="bar">
<img src="img/Imag.png" class="test2" />
<div class="text"> Capgemini Newcomer Application </div>
<img src="img/Test3.png" class="test"/>
</ion-footer>
CSS code
.bar {
position: absolute;
margin-top: 20px;
height: 50px;
border-top: 2px solid #FBC02D;
}
.bar .test {
float: right;
clear: left;
position: fixed;
max-width: 130px;
max-height: 100px;
right: 0;
bottom: 2px;
}
.bar .test2 {
width: 40px;
height: 40px;
bottom: 20px;
}
.bar .text {
text-align: center;
font-size: 6;
bottom: 2px;
}
EDIT
After doing the modifications mentioned below, i got this:
<ion-footer-bar ng-class="{'bar': true}">...</ion-footer>
There are a couple of issues with your CSS that don't work like you would expect:
.bar {
position: absolute;
margin-top: 20px; /* doesn't do anything for position: absolute */
height: 50px;
border-top: 2px solid #FBC02D; /* <-- this will always add the border outside the footer */
}
.bar .test {
float: right;
clear: left;
position: fixed; /* <-- either you float it, or you position it fixed - both together don't make sense */
max-width: 130px;
max-height: 100px;
right: 0;
bottom: 2px;
}
.bar .test2 {
width: 40px;
height: 40px;
bottom: 20px; /* <-- "bottom" on a non-positioned element doesn't do anything */
}
.bar .text {
text-align: center;
font-size: 6; /* <-- font size needs a unit like "px" or "pt" */
bottom: 2px; /* same as above, this should probably be margin-bottom instead */
}
Cleaned up, it could look like this:
.bar {
position: absolute;
height: 50px;
}
.bar .test {
position: fixed;
max-width: 130px;
max-height: 100px;
right: 0;
bottom: 2px;
}
.bar .test2 {
width: 40px;
height: 40px;
margin-bottom: 20px;
}
.bar .text {
text-align: center;
font-size: 6pt;
margin-bottom: 2px;
border-top: 2px solid #FBC02D;
}
This will still overlap the logo with the border, but that's a problem that you need to fix in the logo image.

Icon won't center align in button

I have a button set up like this:
I cannot for the life of me get the icon to sit in the middle of the button.
This is my CSS:
.buttonclass {
width: 30px;
height: 30px;
border-radius: 20px;
background-color: #1DBE60
}
.iconclass {
width: 20px;
height: 20px;
margin: 7.5px;
}
The only caveat is that I need the margin on the iconclass.
Here's a plunk...
http://plnkr.co/edit/6fLYQlpFmDdf7aWenBtp?p=preview
Setting the image as a background-image is probably your best bet.
If you can't do that then I would probably create a css rule for that .iconclass nested in that .buttonclass since you said you cannot remove the margin from the .iconclass directly.
Something like this:
.buttonclass .iconclass{
margin:0;
position:absolute;
top:50%;
left:50%;
transform:translate(-50%, -50%);
}
Updated Plunker.
Look into box-sizing, this will help it contain it's content and you can adjust the width/height from there. http://www.w3schools.com/cssref/css3_pr_box-sizing.asp
Works well like this:
.buttonclass {
width: 30px;
height: 30px;
border-radius: 20px;
background-color: #1DBE60;
box-sizing:content-box;
padding:0px;
}
.iconclass {
width: 20px;
height: 20px;
}
I was toggling your CSS file, and I believe this simple solution works...
you could also resize the ewisth of the icon class, but this seems to be what you're looking for if I'm correct
CSS
.buttonclass {
width: 30px;
height: 30px;
text-align: center;
position: relative;
border-radius: 20px;
background-color: #1DBE60
}
.iconclass {
width:15px;
}
Try the following solution (alter only image class)
.iconclass {
width: 20px;
height: 20px;
margin: 3.4px;
position: absolute;
top: 0;
left: 0;
}
It works for me.
Just use margin: 0px -2px -2px -2px; to the .iconclass.

Right alignment in Form elements wrong

I have a problem that I believe might be pretty stupid, but I can't figure out.
I have a form, where I want to align the elements in both sides, problem is I can't align it to the right (where the red line is), here is a picture to show it:
and here is my SASS (sorry if is not very tidy I been working for a while in it and might be messy):
.contact {
margin: 100px auto 0;
max-width: $half-width;
form {
letter-spacing: 2px;
color: $color4;
input, textarea {
border: 3px solid $color5;
padding: 10px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
font-size: 16px;
background: $color6;
&:focus {
outline: none !important;
border-color: $color3 !important;
}
textarea {
height: 10em;
width: 100%;
overflow: inherit;
}
}
.info-group {
margin-top: 10px;
label {
display: inline-block;
width: 45%;
float: left;
&:nth-child(2) {
float: right !important;
margin: 0 auto;
}
}
}
.tell-group {
width: 100%;
label {
display: inline-block;
margin-top: 10px;
}
textarea {
height: 10em;
width: 100%;
float: left;
}
}
.submit-wrap {
margin-top: 10px;
float: right;
input {
width: 100px;
font-size: 18px;
text-transform: uppercase;
color: $color6;
background-color: $color5;
border: none;
&:hover {
color: $color1;
}
}
}
}
}
Thanks!
padding: 10px; is going to add 20px to the width, this extra width is likely what is causing the problem. You can change the width attribute to width: calc(100% - 20px); to account for the 10px padding on each side of the element.
Here is a list of where calc is supported: http://caniuse.com/#feat=calc
You can also try adding these css rules to the problem elements to move them over:
position: relative;
left: -20px;
You might also have to add position: relative; to the parent element
Here is a fiddle showing the left -20px method: http://jsfiddle.net/0f153w8e/
Side note: you might have to adjust the left amount a little bit to make it exact if your text areas have borders (which they probably do)

css - make div be above page content

I have this drop down menu, that when it's hovered some of the content is going behind another div. It looks like this:
The css for the menu is like this:
.nav-m {
height: 50px;
width: 60px;
display: block;
position: absolute;
z-index: 9999;
overflow-y: hidden;
text-align: center;
position: absolute;
}
.nav-m:hover {
width: 140px;
height: 210px;
}
.nav-m a {
display: none;
text-indent: -9999px;
position: relative;
height: 20px;
padding: 13px 0;
color: #fff !important;
}
nav a:first-child:hover {
text-indent: -9999px;
}
.nav-m:hover>a {
display: block;
}
.nav-m:hover>a:first-child:after {
color: #6daeaf;
background: #505664;
}
.nav-m a:first-child {
display: block;
text-align: center;
margin-bottom: 16px;
cursor: default;
}
.nav-m a:after {
position: absolute;
top: 0;
padding: 12px 0;
width: 60px;
color: #fff;
font-family: 'icons';
font-size: 24px;
display: block;
text-indent: 0;
background: #6daeaf;
}
nav a:hover {
text-indent: 0px;
text-align: left;
margin-left: 70px;
}
.nav-m a:hover:after {
color: #999;
background: #fff;
text-align: center;
margin-left: -70px;
}
.nav-m a:first-child:before {
position: absolute;
text-indent: 0;
top: 55px;
left: 23px;
content: "";
width: 0;
height: 0;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #6daeaf;
}
.nav-m a:first-child:hover:before {
margin-left: -70px;
}
.nav-m a:first-child:after {
left: 0;
content: "m";
background: #656d7e;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.nav-m a:nth-child(2):after {
content: "p";
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.nav-m a:nth-child(3):after {
content: "s";
}
.nav-m a:last-child:after {
content: "e";
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-moz-border-radius-bottomleft: 5px;
-moz-border-radius-bottomright: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
Below the menu div is .container, .row and then a div with class='span12' (I'm using bootstrap)
The HTML looks like this:
<div id="topbg">
<div class="span9">span9 content here</div>
<div class="span3 avatar-holder" >
<nav class="nav-m" onmouseover="">
Menu
Account
Settings
Email
Email
Email
Email
Email
Email
Email
</nav>
</div>
</div>
</div><!--end row-->
</div><!--end topbg-->
<div class='container' style='margin-top:20px;'>
<div class='row'>
<div class='span12' style='margin:0;'>
span 12 content
</div><!--end span12-->
</div><!--end row-->
So, I've tried setting the z-index to -1 on the following divs: .row, .container, .span12 with no luck. I've also tried settings the overflow to visible on every possible div. I can't find the problem here.
Can anyone help me out?
The div is not overlaping the menu. It is the menu items which are not visible.
You have text-indent: -9999px on .nav-m a menu items and you reverted that for first three items thanks to following CSS
.nav-m a:nth-child(3):after {
content: "s";
}
.nav-m a:nth-child(2):after {
content: "p";
}
.nav-m a:first-child:after {
content: "m";
}
Now look at general styles for all your menu items:
.nav-m a:after {
position: absolute;
top: 0;
padding: 12px 0;
width: 60px;
color: #FFF;
font-family: 'icons';
font-size: 24px;
display: block;
text-indent: 0;
background: #6DAEAF;
}
It misses the content property which is crucial here. Without it the pseudo-element :after won't be rendered at all.
To prove that, I prepared a JSFIDDLE with your code (no modifications). It doesn't contain this overlaping div at all but the problem is still present.
If you want to stay with this approach I'd suggest a minor change which will spare you lots of CSS.
To every menu item anchor add an attribute data-shortcut which will hold the first letter of the menu item
Settings
and so on... Now you can access this attribute in CSS content property
content: attr(data-shortcut);
Thanks to that you don't need to define CSS for every menu item with different first letter.
Try to give z-index value more than div on which it is overlapping.
Example : If div1 contains z-index 10, then give greater z-index to <nav>which is hiding behind `div1'.
Z-index only effects elements that have a position set to them. Make sure you have position:relative or position:absolute set to both the dropdown and the div covering it.