I'm following this SO post here and the p element is not centering.
Basically I gave the containing div a width and height and then set text align attribute to center for the p element inside the div. No go.
What can I try next?
The containing div is id=Y1aa
I only need horizontal centering for now.
#Y1 {
z-index: 4000;
position: relative;
width: 100%;
height: 30px;
background: #ffffff;
opacity: .95;
}
#Y1a {
position: relative;
width: 320px;
height: 30px;
margin: 0 auto;
border-left: dotted 1px #000000;
border-right: dotted 1px #000000;
}
#Y1aa {
position: relative;
width: 320px;
height: 30px;
top: 5px;
}
.top {
color: #000000;
display: inline;
font-size: 9px;
font-weight: bold;
font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
text-align: center;
line-height: 10px;
}
<div id='Y1'>
<div id='Y1a'>
<div id="Y1aa">
<p class="top">Foo</p>
</div>
</div>
</div>
Change display:inline to display:block in your top class, or delete the display style all together.
You can remove from your .top class this: display: inline;.
#Y1 {
z-index: 4000;
position: relative;
width: 100%;
height: 30px;
background: #ffffff;
opacity: .95;
}
#Y1a {
position: relative;
width: 320px;
height: 30px;
margin: 0 auto;
border-left: dotted 1px #000000;
border-right: dotted 1px #000000;
}
#Y1aa {
position: relative;
width: 320px;
height: 30px;
top: 5px;
}
.top {
color: #000000;
font-size: 9px;
font-weight: bold;
font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
text-align: center;
line-height: 10px;
}
<div id='Y1'>
<div id='Y1a'>
<div id="Y1aa">
<p class="top">O: 832-418-9180 M: 281-923-3638 S: 281-968-0727</p>
</div>
Alternatively, you could add text-align: center to #Y1aa if you need to keep the p as an inline element.
#Y1 {
z-index: 4000;
position: relative;
width: 100%;
height: 30px;
background: #ffffff;
opacity: .95;
}
#Y1a {
position: relative;
width: 320px;
height: 30px;
margin: 0 auto;
border-left: dotted 1px #000000;
border-right: dotted 1px #000000;
}
#Y1aa {
position: relative;
width: 320px;
height: 30px;
top: 5px;
text-align: center;
}
.top {
color: #000000;
display: inline;
font-size: 9px;
font-weight: bold;
font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
text-align: center;
line-height: 10px;
}
<div id='Y1'>
<div id='Y1a'>
<div id="Y1aa">
<p class="top">O: 832-418-9180 M: 281-923-3638 S: 281-968-0727</p>
</div>
</div>
</div>
To center a paragraph inside a div you will have to use the margin attribute in the CSS style for the paragraph
In this example i am centering the first paragraph inside the div with class 'wrap'
.wrap p:first-child {
text-align:center;
margin: 0 auto;
}
<div class="wrap">
<p>Some p tag</p>
</div>
Related
hej there.
i created an svg from a complex image, showing a city map. including tiny green boxes to mark certain houses, etc. with A,B,C or other. (can be seen in screenshot)
on mouseover, a div box should appear (with more than a tooltip-line - as shown in the screenshot and by code) - positioned within the viewbox and next to the pointer.
alternatively it could be an overlay - centered within the viewbox - that disappears when moving the pointer away from the anker.
i was not able to achieve this with plain css, working with combined #C .mark #markc (for example) and visibility.
SVG-'box':
<g id="C">
<rect class="cls-245" x="88.2" y="523.4" width="11.2" height="9.26"/>
<g class="cls-2"><path class="cls-6" d="M92.9,528.7c0,.9.4,1.4,1,1.4s.9-.4.9-1h1.3v.2a2,2,0,0,1-2.2,1.9,2.2,2.2,0,0,1-2.3-2.5v-.6a2.2,2.2,0,0,1,2.3-2.5,2,2,0,0,1,2.2,1.9v.2H94.8c0-.6-.3-1-.9-1s-1,.5-1,1.4Z"/></g>
</g>
DIV to appear:
<div class="mark" id="markc">
<div class="thead">
<div class="pin">C</div> <div class="label">culpepper crescent</div>
</div>
<div class="tdetail">
<p class="descrp">Bewohner</p>
<p class="peops">Heathcote Barbbary<br>Lynn Stark</p>
</div>
</div>
CSS code:
#karte {
width: 90%;
position: relative;
margin: auto;
margin-top: 70px;
border: #fff solid 10px;
outline: #ceccc4 solid 1px;
}
.mark {
width: 250px;
min-height: 100px;
position: relative;
display: flex;
flex-direction: column;
background-color: rgb(255, 255, 255);
line-height: 110%;
font-weight: normal;
z-index: 1;
border: 10px solid #fff;
}
.thead {
display: inline-flex;
background-position-y: bottom;
font-family: Roboto Slab;
letter-spacing: .5px;
text-transform: uppercase;
}
.pin {
background-color: #4e9295;
width: 10%;
text-align: center;
font-size: 15px;
color: #fff;
padding: 8px;
}
.label {
background-color: #D6EBEC;
width: 90%;
font-size: 12px;
text-align: left;
padding: 8px;
}
.tdetail {
background: #E9E9E9;
color: #4d4e52;
font-family: calibri;
min-height: 75px;
text-align: left;
padding: 0px 10px 10px 10px;
border-top: 8px solid #fff;
}
.tdetail .descrp {
color: #4d4e52;
text-transform: uppercase;
margin-bottom: -10px;
font-weight: 600;
font-size: 15px;
}
.tdetail .peops {
font-weight: 300;
font-size: 12px;
padding: 8px;
}
it is supposed to be a 'present'. i have nearly no experience with javascript - i am happy to use it as a solution, but might need a 'clear' instruction. it is up to 25 'pins' on the complete map.
many thanks!
screenshot
Here's a very simple example implementation to get you started.
You'll need to do a little more work to make it work with more than one tooltip. Not also that it assumes your map is at 1:1. If your SVG has a viewBox or is otherwise scaled, you need to do some work to get the correct coordinates to show the tooltip at. You can find out how to do that by searching Stack Overflow.
var C = document.getElementById("C");
// Add an event handler to C that fires when the mouse moves over it
C.addEventListener("mousemove", function(evt) {
let markc = document.getElementById("markc");
// Position the tooltip element near the mouse
markc.style.left = (evt.offsetX + 10) + "px";
markc.style.top = evt.offsetY + "px";
// Show the tooltip element
markc.classList.remove("hidden");
});
// Add an event handler to C that fires when the mouse leaves the element
C.addEventListener("mouseout", function(evt) {
hideElement("markc");
});
// Hide the element with given id
function hideElement(id) {
document.getElementById(id).classList.add("hidden");
}
// Start out with the tooltip hidden
hideElement("markc");
#karte {
width: 90%;
position: relative;
margin: auto;
margin-top: 70px;
border: #fff solid 10px;
outline: #ceccc4 solid 1px;
}
.mark {
width: 250px;
min-height: 100px;
position: absolute; /* changed to absolute so we can position it where we want */
display: flex;
flex-direction: column;
background-color: rgb(255, 255, 255);
line-height: 110%;
font-weight: normal;
z-index: 1;
border: 10px solid #fff;
}
.thead {
display: inline-flex;
background-position-y: bottom;
font-family: Roboto Slab;
letter-spacing: .5px;
text-transform: uppercase;
}
.pin {
background-color: #4e9295;
width: 10%;
text-align: center;
font-size: 15px;
color: #fff;
padding: 8px;
}
.label {
background-color: #D6EBEC;
width: 90%;
font-size: 12px;
text-align: left;
padding: 8px;
}
.tdetail {
background: #E9E9E9;
color: #4d4e52;
font-family: calibri;
min-height: 75px;
text-align: left;
padding: 0px 10px 10px 10px;
border-top: 8px solid #fff;
}
.tdetail .descrp {
color: #4d4e52;
text-transform: uppercase;
margin-bottom: -10px;
font-weight: 600;
font-size: 15px;
}
.tdetail .peops {
font-weight: 300;
font-size: 12px;
padding: 8px;
}
.cls-245 {
fill: green;
}
.cls-6 {
fill: white;
}
/* Needs to be position relative so we can later position the tooltip relative to it. */
.container {
position: relative;
}
/* class used to hide the tooltip when we don't want it showing */
.hidden {
display: none;
}
<div class="container">
<svg width="400" height="700">
<g id="C">
<rect class="cls-245" x="88.2" y="523.4" width="11.2" height="9.26"/>
<g class="cls-2"><path class="cls-6" d="M92.9,528.7c0,.9.4,1.4,1,1.4s.9-.4.9-1h1.3v.2a2,2,0,0,1-2.2,1.9,2.2,2.2,0,0,1-2.3-2.5v-.6a2.2,2.2,0,0,1,2.3-2.5,2,2,0,0,1,2.2,1.9v.2H94.8c0-.6-.3-1-.9-1s-1,.5-1,1.4Z"/></g>
</g>
</svg>
<div class="mark" id="markc">
<div class="thead">
<div class="pin">C</div>
<div class="label">culpepper crescent</div>
</div>
<div class="tdetail">
<p class="descrp">Bewohner</p>
<p class="peops">Heathcote Barbbary<br>Lynn Stark</p>
</div>
</div>
</div>
<body onload="load_animes()">
<div class="head">
<!-- <h1 id="head_title">Hello</h1> -->
<img src="https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/7206d8a9-d46d-4479-b47a-8cf6d05bc830/d7zzah3-c53850a6-5d66-437b-a581-99d84fea1923.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOiIsImlzcyI6InVybjphcHA6Iiwib2JqIjpbW3sicGF0aCI6IlwvZlwvNzIwNmQ4YTktZDQ2ZC00NDc5LWI0N2EtOGNmNmQwNWJjODMwXC9kN3p6YWgzLWM1Mzg1MGE2LTVkNjYtNDM3Yi1hNTgxLTk5ZDg0ZmVhMTkyMy5wbmcifV1dLCJhdWQiOlsidXJuOnNlcnZpY2U6ZmlsZS5kb3dubG9hZCJdfQ.oSQAAL-K2KoIhZJTBTpnvqqcy2cC8QjmgsUwlsS-0Uk" id="head_bg">
<h1 id="desc">
This is a website where I post my shitty reviews about anime that I have watched. All anime are sorted based on the first alphabet of their names
</h1>
<h1 id="note">
<strong>Note:</strong> There will be spoilers in my reviews
</h1>
</div>
<div id="view">
<div id="layer"></div>
<div id="content">
<h1 id="view_title"></h1>
<h2 id="view_genres"></h2>
<p id="view_note">Note: I don't assign the genres according to MAL, I assign the genres based on my own opinion</p>
<h3 id="view_rating"></h3>
<h4 id="view_review"></h4>
<button id="back" onclick="back()">Back To List</button>
<img id="view_img">
</div>
</div>
my style:
body {
background-color: #28282B;
/* background-image: url("img_tree.gif"); */
background-repeat: no-repeat;
background-attachment: fixed;
height: 100%;
}
*{
font-family: Arial, Helvetica, sans-serif;
}
#view{
z-index: 0;
position: relative;
height: max-content;
margin: -8px;
}
#view #layer {
background-color: black;
opacity: 0.5;
height: max-content;
width: 100%;
position: absolute;
z-index: 0;
}
#view div {
position: absolute;
}
#view #view_title{
font-size: 4rem;
color: white;
margin-left: 2%;
z-index: 1;
}
#view #view_genres{
margin-left: 2%;
}
#view #view_note{
color: rgb(243, 226, 226);
font-size: 1.5rem;
border-radius: 10px;
margin-left: 2%;
font-weight: bolder;
}
#view #view_rating{
color: white;
margin-left: 2%;
font-size: 1.5rem;
font-family: 'open sans',arial,sans-serif;
}
#view #view_review{
background-color: #18181a;
color: white;
font-size: 2rem;
margin-left: 5%;
margin-right: 5%;
border-radius: 5px;
z-index: 1;
font-weight: lighter;
}
#view #view_img{
max-height: 80%;
max-width: 70%;
z-index: 0;
display: block;
margin-left: auto;
margin-right: auto;
}
#view #back:hover{
color: #FFD700;
}
#view #back{
font-size: 3.5rem;
background-color: #18181a; /* Green */
border: none;
color: white;
text-align: center;
outline: none;
border-radius: 5px;
font-family: Arial, Helvetica, sans-serif;
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 5%;
margin-bottom: 5%;
}
i set my #view element (which is the parent element) to height: max-content but it isn't setting the height, the height is still 0, but the width is maxed and as u can see, there are no other parent elements containing #view. I've changed the body's style to height: max-content as well but it ain't working
How to get the text wrapped under the points?
https://codepen.io/neginbasiri/pen/ZEGReRZ
<div class="pointLine__PointLine-wgyo1p-1 bUhvVh">
<svg class="icon--icon--base--17 pointLine__RooIcon-wgyo1p-0 iBQvHK">IMAGE</svg>
<div class="pointLine__Content-wgyo1p-2 cPwDGx"><div class="pointLine__Point-wgyo1p-3
pointLine__DefaultPoint-wgyo1p-4 enMiay">16,000</div><p class="Text__StyledText-zy9rxk-0 dufgDt">
Points when you join or switch <span id="super-node-187"><sup class="super--super--root--13">
<span>3</span></sup> </span></p></div>
In the example switch should show under 16,000.
.bUhvVh {
display: flex;
margin-bottom: 20px;
width: 300px;
}
.iBQvHK {
color: #e40000;
font-size: 24px;
margin-right: 10px;
border: 1px solid red;
width: 20px;
}
.icon--icon--base--17 {
height: 1em;
min-width: 1em;
vertical-align: middle;
fill: currentColor;
}
.cPwDGx {
font-family: Ciutadella Regular;
font-size: 18px;
color: #555;
letter-spacing: normal;
line-height: 1.5;
}
.enMiay {
float: left;
font-family: Ciutadella Medium;
margin-right: 4px;
position: relative;
color: #323232;
}
.dufgDt {
margin: 0;
font-family: 'Ciutadella Regular',sans-serif;
font-size: 18px;
color: #555;
letter-spacing: normal;
line-height: 1.5;
}
<div class="pointLine__PointLine-wgyo1p-1 bUhvVh">
<svg class="icon--icon--base--17 pointLine__RooIcon-wgyo1p-0 iBQvHK">IMAGE</svg>
<div class="pointLine__Content-wgyo1p-2 cPwDGx"><div class="pointLine__Point-wgyo1p-3 pointLine__DefaultPoint-wgyo1p-4 enMiay">16,000</div><p class="Text__StyledText-zy9rxk-0 dufgDt"> Points when you join or switch <span id="super-node-187"><sup class="super--super--root--13"><span>3</span></sup> </span></p></div>
</div>
Remove display: flex; flex: 1 from .cPwDGx.
Remove display: inline-block from .enMiay and add float: left for this element.
Update width to min-width for icon--icon--base--17. It will not shrink if text is larger.
Refer : https://codepen.io/bala_tamizh/pen/WNvyEPg
You can visit the site I am working on here.
You can see what I am going for. I want the bottom right box to mimic the top right box in its positioning, but for some reason it refuses to fill the rest its parent div and opts to stack vertically. Even without content the background stops about half way through the box. I have it set to float left (something that shouldn't be necessary as div children should take their parent's width automatically), so I'm guessing there is something actually there but I cannot tell what. I have tried to clear and such but no luck there either. Is there a way to get that bottom right div to actually fill the parent div?
Here is my HTML
<div id="menu-ad">
<div>
<p class="titles">Our Fare</p>
<p id="ad">Our lunch and dinner menus feature European inspired comfort food accompanied by an extensive bar.</p>
VIEW MENU
</div>
</div><!--end menu ad-->
<div id="hours">
<div>
<p class="titles">Hours</p>
<p class="subtitles">Lunch</p>
<p class="subtitles">Dinner</p>
<p class="subtitles">Bar</p>
</div>
<div>
<p class="hours">Mon-Fri 11-4</p>
<p class="hours">Mon-Sat 4-12</p>
<p class="hours">Mon-Sat 4-12</p>
</div>
</div><!--end hours-->
And my CSS
/*menu ad*/
div#menu-ad {
position: relative;
margin-right: -11px;
margin-top: -11px;
width: 268px;
height: auto;
float: right;
padding: 11px 11px 10px 10px;
border-left: 2px solid #b9aea3;
border-bottom: 2px solid #b9aea3;
overflow: hidden;
}
div#menu-ad div {
background: #f9f4df;
padding: 1.9rem 4rem 2.5rem 2.5rem;
height: 200px;
display: inline-block;
}
.titles {
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 2.5rem;
color: #d6832e;
}
#ad {
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 1.6rem;
line-height: 1.35;
color: #4f4d4b;
margin-top: .5rem;
width: auto;
}
a#button {
padding: .6rem 1.3rem .6rem 1.3rem;
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 1.8rem;
color: #fff;
background: #d6832e;
text-align: center;
vertical-align: middle;
text-decoration: none;
position: absolute;
float: left;
bottom: 3.5rem;
}
/*hours*/
div#hours {
position: relative;
margin-top: -1px;
margin-right: -11px;
width: 268px;
height: auto;
float: right;
padding: 11px 11px 10px 10px;
border-left: 2px solid #b9aea3;
}
div#hours div {
background: #f9f4df;
padding: 1.9rem 4rem 2.5rem 2.5rem;
width: auto;
height: 150px;
display: inline-block;
}
.subtitles {
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 2rem;
color: #4f4d4b;
text-align: left;
line-height: 2;
}
.hours {
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 1.7rem;
color: #4f4d4b;
text-align: right;
line-height: 2;
}
Thanks for any help or advice!
If you change your structure a little, it might help you. Instead of trying to float to divs side by side, you could just join them together kinda like I did with the HTML and css below. I added comments where I changed stuff in the css.
HTML
<div id="menu-ad">
<div>
<p class="titles">Our Fare</p>
<p id="ad">Our lunch and dinner menus feature European inspired comfort food accompanied by an extensive bar.</p>
VIEW MENU
</div>
</div><!--end menu ad-->
<div id="hours">
<div>
<p class="titles">Hours</p>
<p>
<span class="subtitles">Lunch</span>
<span class="hours">Mon-Fri 11-4</span>
</p>
<p>
<span class="subtitles">Dinner</span>
<span class="hours">Mon-Sat 4-12</span>
</p>
<p>
<span class="subtitles">Bar</span>
<span class="hours">Mon-Sat 4-12</span>
</p>
</div>
</div><!--end hours-->
CSS:
/*menu ad*/
div#menu-ad {
position: relative;
margin-right: -11px;
margin-top: -11px;
width: 268px;
height: auto;
float: right;
padding: 11px 11px 10px 10px;
border-left: 2px solid #b9aea3;
border-bottom: 2px solid #b9aea3;
overflow: hidden;
}
div#menu-ad div {
background: #f9f4df;
padding: 1.9rem 4rem 2.5rem 2.5rem;
height: 200px;
display: inline-block;
}
.titles {
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 2.5rem;
color: #d6832e;
}
#ad {
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 1.6rem;
line-height: 1.35;
color: #4f4d4b;
margin-top: .5rem;
width: auto;
}
a#button {
padding: .6rem 1.3rem .6rem 1.3rem;
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 1.8rem;
color: #fff;
background: #d6832e;
text-align: center;
vertical-align: middle;
text-decoration: none;
position: absolute;
float: left;
bottom: 3.5rem;
}
/*hours*/
div#hours {
position: relative;
margin-top: -1px;
margin-right: -11px;
width: 268px;
height: auto;
float: right;
padding: 11px 11px 10px 10px;
border-left: 2px solid #b9aea3;
}
div#hours div {
background: #f9f4df;
padding: 1.9rem 4rem 2.5rem 2.5rem;
width: auto;
height: 150px;
/***** Removed Display:inline-block *****/
}
.subtitles {
float:left; /**** Added ****/
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 2rem;
color: #4f4d4b;
text-align: left;
line-height: 2;
}
.hours {
float:right; /**** Added ****/
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 1.7rem;
color: #4f4d4b;
text-align: right;
line-height: 2;
}
#hours p {clear:both;} /**** Added ****/
All you need to do is to decrease the inner-div size that fits to your #hours div and assign a class to each of the inner div and float them left and right.
Example
<div id="hours">
<div class="left">
<p class="titles">Hours</p>
<p class="subtitles">Lunch</p>
<p class="subtitles">Dinner</p>
<p class="subtitles">Bar</p>
</div>
<div class="right">
<p class="hours">Mon-Fri 11-4</p>
<p class="hours">Mon-Sat 4-12</p>
<p class="hours">Mon-Sat 4-12</p>
</div>
</div><!--end hours-->
CSS:
#hours .left
{
float: left;
}
#hours .right
{
float: right;
}
It will help for sure. Also start using browser`s consoles. They ease your life.
I take it your trying to make the Hours take up the entire box?
If so, add this code to it:
height: 100%;
width: 100%;
padding: 0px;
Use followig. Those which are commented in here, need to remove form your code.
div.container {
/*height: 460px;*/
/*padding: 10px*/
padding: 10px 10px 0px; /* bottom padding 0px */
}
div#hours div {
/*inline-block*/
}
Now add following after ending tag of #hours.
<div style="clear:both;"></div>
To make #hours div look nice, use following.
<div id="hours">
<h3 class="titles">Hours</h3>
<dl>
<dt>Lunch</dt>
<dd>Mon-Fri 11-4</dd>
<dt>Dinner</dt>
<dd>Mon-Sat 4-12</dd>
<dt>Bar</dt>
<dd>Mon-Sat 4-12</dd>
</dl>
</div><!--end hours-->
CSS Styles -
#hours dl,
#hours dt,
#hours dd {
margin: 0;
padding: 0;
}
#hours dl {
width: 100%;
float: left;
clear: both;
}
#hours dl dt {
float: left;
clear: left;
width: 45%;
}
#hours dl dd {
float: left;
}
I'm sure one line of code will change this, but can anyone tell me why there is a gap between my divs for "About" and "Latest"? I've put margin and padding to 0 too many places already. Thanks:
http://jsfiddle.net/PfdRE/
HTML:
<body>
<div id="header" border="0">
<div class="header_logo"><img src="images/logo.png" height="100px" alt="Ashley Lincoln Designs"></div>
<div class="header_button"><span>Contact</span></div>
<div class="header_button"><span>Archive</span></div>
<div class="header_button"><span>Latest</span></div>
<div class="header_button"><span>About</span></div>
</div>
//rest of code...
CSS:
{
margin: 0;
padding: 0;
}
body {
background-color: #174C4F;
margin: 0;
padding: 0;
}
#header {
width: 100%;
height: 100px;
margin: 0;
padding: 0;
background-color: #F5E9BE;
color: #207178;
}
.header_logo {
height: 100px;
margin: 0 auto;
padding: 0;
color: #207178;
font-family: "Verdana", Verdana, sans-serif;
font-size: 20px;
text-align: center;
text-transform:uppercase;
text-indent: 0px;
display:inline-block;
background-color: #F5E9BE;
float: left;
position:absolute;
left:75px;
}
.header_button {
width: 125px;
margin: 0 auto;
padding: 0;
color: #207178;
font-family: "Verdana", Verdana, sans-serif;
font-size: 20px;
text-align: center;
text-transform:uppercase;
text-indent: 0px;
display:inline-block;
background-color: #F5E9BE;
float: right;
position:relative;
right:75px;
}
in your css class .about get rid of;
display:inline-block