This question already has answers here:
Two divs side by side - Fluid display [duplicate]
(9 answers)
How to place div side by side
(7 answers)
Closed 2 years ago.
I'm trying to horizontally align two block elements and "display: inline-block" isn't working. I'm wondering if this is because I have unique margins set for each element. I don't understand CSS from a theoretical level. I will be adding a line to connect them visually once they're on the same horizontal line.
h2 {
padding: 75px;
margin-left: 30px;
font-family: 'Nunito Sans', sans-serif;
}
#cal {
font-family: 'Roboto', sans-serif;
border: solid;
border-radius: 25px;
padding: 10px;
margin-left: 350px;
margin-right: 250px;
}
<h2 id="#about-me">About Me</h2>
<p id="cal">My name is Cal. I'm 28 years old and live in Boston, Massachusetts. I'm from NYC originally. I'm passionate about web design and SEO. I built this site to feature my work.</p>
Related
This question already has answers here:
Border-radius in percentage (%) and pixels (px) or em
(3 answers)
Closed 1 year ago.
I'm trying to make a button perfectly curved using only less/css and html, but I can't figure out how to make it perfectly curved instead of that ugly html (my opinion) curve.
How I'm Doing It:
HTML
<div class = "scrollToTop">
<button>up top</button>
</div>
LESS/CSS
#fullred: #FF0000;
.scrollToTop button {
.scrollToTop a button {
scroll-behavior: smooth;
background-color: #fullred;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border-radius: 7%;
margin: 1%;
}
}
What am I doing wrong?
Use same width and height values and then adjust the border-radius as per your smoothess taste.. perfered border-radius should be between 8-12%
Its easier to define border-radius in pixels. As explained here Border-radius in percentage (%) and pixels (px) or em defining border-radius in % might give unexpected results.
This question already has answers here:
Understanding CSS selector priority / specificity
(4 answers)
Closed 2 years ago.
If I have a css file, mystyle.css:
body {
font-family: OpenSans, Arial, sans-serif;
font-size: 14px;
}
.news {
width: 800px;
background-color: #99EBFF;
}
but I wanted to override it for a specific part of the site for (in another CSS file, for example, cms-news-pages.css), e.g.:
.news {
padding: 2.5px;
width: 600px;
background-color: #FFE6B3 !important;
}
what would be a preferable alternative to !important for a class without getting into too much code spaghetti?
If anyone could advise me I'd be grateful for this, trying to make cleaner CSS coding.
Try to give more prefrence using parent selectors
Suppose .news has parent with classname .news-container
Then you can use
.news-container .news {
background-color: #FFE6B3;
}
This will override css property of the .news.
This question already has answers here:
HTML Div border not showing
(3 answers)
Closed 2 years ago.
I am trying to make a foot print for a cool look, but it won't show
here's my code:
.footprint {
width: 100px;
height: 50px;
border-color: gray;
border: 3px;
border-radius: 20px;
}
<div class="footprint"></div>
welcome to SO!
Somebody already found a solution to your problem here:
CSS Property Border-Color Not Working
A div by default has no border-style and no border-width, therefore the border will not be shown.
This question already has answers here:
Why does margin-top work with inline-block but not with inline?
(3 answers)
Closed 3 years ago.
I have a "Read more" button on Section-e that acts weird: the margins are not responding except for left one.
GitHub Repo: https://github.com/CalogerN/Conquer
Live Preview: https://calogern.github.io/Conquer/
I tried debugging, but I found nothing.
.section-e__btn {
align-self: flex-start;
margin: 28px 0px 30px 20px;
padding: 15px 30px;
background-color: white;
font-family: "Open Sans";
}
<div class="section-e__column1">
Read more
</div>
Use display: block or display: inline-block to set margins on the <a> tag.
This question already has answers here:
My inline-block elements are not lining up properly
(5 answers)
Closed 7 years ago.
HTML
<span class="symbol">$</span>
<span class="value">400</span>
This displays both "$" and "400" at the same level.
The moment I add
CSS
.symbol {
font-size: 2em;
}
then, "400" is pushed down.
Question: Why is "400/.value" affected by changes to "$/.symbol" ?
Thanks.
http://codepen.io/anon/pen/emLLrm
This question realistically is about vertically aligning, and can be solved using
vertical-align:middle
or
vertical-align:top;
to override the default baseline (which by default is set to the bottom).
Demo:
.symbol {
font-size: 2em;
vertical-align:middle;
}
<span class="symbol">$</span>
<span class="value">400</span>
In addition if you want more control over the positioning in relation to the number, use position:relative and top: on the symbol to position where you'd like. For instance:
.symbol {
font-size: 2em;
position:relative;
top: .3em; /* or 10px if you want to use pixels */
}