Icon won't center align in button - html

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.

Related

How do I stop my links from being clicked beneath it?

For some reason instead of only being able to click the links by clicking on the text, you can also click below it on empty space.
My friend said I had to reduce div size but I'm not quite sure on what he meant.
#video {
position: fixed;
right: 0;
bottom: 0;
min-height: 100%;
min-width: 100%;
}
#devil,
#steam,
#youtube {
display: block;
margin-left: auto;
margin-right: auto;
height: 230px;
width: 230px;
position: relative;
}
#steam,
#youtube {
text-decoration: none;
font-family: cursive;
font-style: oblique;
}
#devil {
border-radius: 120px;
top: 250px;
right: 20px;
}
#steam {
top: 280px;
left: 10px;
}
#youtube {
top: 50px;
left: 115px;
}
a:link,
a:visited {
color: forestgreen;
}
<div>
<img id="devil" src="img/frizzy.jpg">
</div>
<div>
<a id="steam" href="https://steamcommunity.com/id/impenetrable" target="_blank">steam</a>
<a id="youtube" href="https://www.youtube.com/c/ItsFrizzy" target="_blank">youtube</a>
</div>
Your problem is probably in here:
#devil,
#steam,
#youtube {
display: block;
margin-left: auto;
margin-right: auto;
height: 230px;
width: 230px;
position: relative;
}
You shouldn't need to set the height or width for your links, since they will be automatically set based on the text. You can use something like firefox tools to look at the bounding block of your links and see what's giving them the big space to click. You can even mess with the parameters here to suit your liking.
In your css, you specify height: 230px; for your element that holds the link. Decrease this size to remove the blank space that also responds to your mouse.
As suggested, use a border or background color to help indicate where your elements are, or use the development console (F12 in Chrome) to find your element sizes.
Instead of setting height to links you should set font-size for them and if this didn’t help set line-height same as font-size value.
You are getting a height on your anchors because you are applying a height to them (you should remove this). Also, I wouldn't use absolute or relative positioning for this as you do not need it. I would envelope your image and your social links in their own containers and position them. Here is an example of what I am talking about.
.container {
margin-top: 20px;
}
#video {
position: fixed;
right: 0;
bottom: 0;
min-height: 100%;
min-width: 100%;
}
.social_container {
margin: 0px auto;
padding: 10px;
width: 200px;
}
#steam,
#youtube {
margin: 0px auto;
width: 80px;
display: inline-block;
text-decoration: none;
font-family: cursive;
font-style: oblique;
text-align: center;
}
#devil {
border-radius: 120px;
display: block;
margin-left: auto;
margin-right: auto;
height: 230px;
width: 230px;
position: relative;
}
a:link,
a:visited {
color: forestgreen;
}
<div class="container">
<img id="devil" src="img/frizzy.jpg">
</div>
<div class="social_container">
<a id="steam" href="https://steamcommunity.com/id/impenetrable" target="_blank">steam</a>
<a id="youtube" href="https://www.youtube.com/c/ItsFrizzy" target="_blank">youtube</a>
</div>

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.

text over images in html css

i am trying to put text over image it works but is there a better way to do it. should i use a different html tag for the text.
any suggestions
http://jsfiddle.net/8rDda/
body{
background-color:#F0F0F0 ;
color:#000305;
font-size: 87.5%;
font-family: Arial,'Lucida Sans Unicode';
line-height: 1.5;
text-align: left;
width:80%;
margin:2% auto;
}
.main {
width:45%;
height:300px;
background-color: #20b2aa;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
.main img{
width:80%;
height:auto;
margin: 6% 10%;
float: left;
}
.main h2 {
color:white;
position: absolute;
margin:50px;
margin-left: 50px;
width: 100%;
}
Maybe one solution could be, that you set the image as background-image for your div. And edit the test in it. So you jut have a single div, which you must edit.
http://jsfiddle.net/QX36R/1/
http://jsfiddle.net/8rDda/1/
I would use absolute positioning instead of float.
.main {
width:45%;
height:300px;
background-color: #20b2aa;
border-radius: 5px;
position: relative; //keep children absolutely position constrained to this element.
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
.main h2 {
color:white;
position: absolute;
margin: 6% 10%;
top: 0;
left: 0;
}
You could also use z-index and different divs. But at last you need position:absolute; with different positions or margin-top: -whatever with position:relative;. There is not really a right or wrong approach to do this. As long as it works on your site, it is all fine.
You can use <div> tag means creating one div and put it on the top of image or set any position or else link it with another div which will be your image. There are plenty of things you can do with <div> tag.
Example.
<div style="abcd">
top: 99;
left: 99;
position: absolute;
z-index: 1;
visibility: show;">
<!-- content will go here -->
</div>

HTML text aligned strange

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.

Expand text outside of container

I am trying to figure out how to expand my text outside of its container. The desired effect is to have a the text expand larger than its container. Ex.//
I'm not sure how to start with this. I'm new to HTML and CSS and could use some help :)
Here's one way of doing it:
<div class="container"><span>EXAMPLE</span></div>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
​.container {
background: #ddd;
font-size: 30px;
width: 130px;
height: 15px;
overflow: hidden;
}
.container span {
position: relative;
top: -10px;
left: -7px;
}
http://jsfiddle.net/ZnxrT/
Note: The top/left offsets are arbitrary units. You would need to tweak them to suit your requirements.
You should apply a fixed size to the box containing the text: EXAMPLE.
After that you should put the text in the middle and size the letters so the are larger than the space of the box and apply an overflow: hidden
It should be something like that:
.box{
width: 50px;
height: 10px;
overflow: hidden;
margin: auto;
background-color: gray;
}
.text{
color: red;
font-size: 14px;
text-align:center
vertical-align:middle;
}
Here is a working example
http://jsfiddle.net/8CaQx/
<div id="outer"><div id="inner">TEXT</div></div>​
#outer {
height: 36px;
width: 140px;
overflow: hidden;
background-color: black;
}
#inner {
position: relative;
top: -18px;
left: -10px;
font-size: 60px;
text-align: center;
vertical-align: middle;
font-family: arial, sans serif;
font-weight: 900;
color: red;
}​
You are probably looking for the CSS overflow property.
http://www.w3schools.com/cssref/pr_pos_overflow.asp
Please see this fiddle for the code to recreate the above example: http://jsfiddle.net/E5atK/