I have a parent element that has dynamic text in it that needs to be confined into a certain area. I had users that where writing sentences without using spaces (example:yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy etc...) This was breaking the structure of my styled text area.
#ProfileCommentBody{ width:500px; font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333333; margin:15px 0px 0px 20px; float:left; background-color:#EAF7FB; padding:10px 10px 10px 10px; position:relative; overflow:hidden;}
I used overflow:hidden,as you can see above in the css code, and it solved the problem but created a new problem. I have another another element that is a image that is absolutely positioned that completes the style of my speech bubble ( the above element is the speech bubble) and when I have the above element on overflow:hidden it make that image disappear. I have tried z-index and that does not work.
.ProfileCommentTail{background:url(images/speechBubbleTail.png) no-repeat top left; width:15px; height:10px; position:absolute; top:20px; left:-15px;}
Is there a different option to use besides overflow:hidden or is there something I can do to counteract the unwanted part of what the overflow:hidden is doing?
html structure:
<div id='ProfileCommentBody' class='round_10px'>
<div id='CommentNameProfile'>
<div class='ProfileCommentTail'> </div>
<a href='http://www.blahblahblah.org/Profile.php?id=<?php echo $poster->id; ?>'>
<?php echo $poster->first_name. " ". $poster->last_name; ?> says...
</a>
</div>
</div>
Here is an example of an imgage of what it is doing now,which is wrong (missing speech bubble tail to the right of the polaroid, and the left of the speech bubble) overflow:hidden is causing this to disappear, but fixing another problem I was having:
(source: cysticlife.org)
here is what it is SUPPOSED to look like, notice the tiny blue speech bubble tail connected to the speech bubble:
(source: cysticlife.org)
<div id="blah">
<div class='ProfileCommentTail'> </div>
<div id='ProfileCommentBody' class='round_10px'>
<div id='CommentNameProfile'>
<a href='http://www.blahblahblah.org/Profile.php?id=<?php echo $poster->id; ?>'>
<?php echo $poster->first_name. " ". $poster->last_name; ?> says...
</a>
</div>
</div>
</div>
This is what I meant by my initial comment. CSS such as:
#blah { position:relative; }
Then again, because there is no layout/design/comp links it's hard to see what you are describing. I suggest posting visual details for visual problems.
Related
I have my profile image and below it I want to place my name and a few things about me. I don't know what to use for the image div or if I even need a div for it. Are the h1 and p elements used properly?
Snippet
<div class="profile">
<div><img src="profile_image.jpg"></div>
<h1>first last</h1>
<p>Coffee snob.</p>
</div>
Full Body HTML
<body>
<div class="page">
<div class="profile">
<div><img src="profile_image.jpg"></div>
<h1>first last</h1>
<p>Coffee snob.</p>
</div>
<div class="sites">
<ul>
<li><img src=""> <img src=""></li>
</ul>
</div>
</div>
</body>
The rest of the site are just app icons taking to my social media sites. There's no other content. My site also doesn't have a header or footer. Not sure if my profile class should be considered the header at this point for good SEO.
You do not need to put the div around the image. Just style it to display: block (img defaults to display: inline)
<div class="profile">
<img style="display: block" src="profile_image.jpg">
<h1>first last</h1>
<p>Coffee snob.</p>
</div>
Otherwise, the rest of the code is perfectly fine.
It does depend of what exactly you want to do with it but if I understand your question.
You don't need divs for your image just set up different image classes in your CSS.
.image1
{
width:100px;
height:100px;
}
Then your HTML would look like
<img src="profile_image.jpg" class="image1">
Check out http://www.w3schools.com/css/css_align.asp for more information about how to actually set up alignments in your CSS
It might be worth using a div to style your text into a block or format it to look nice, etc. But you don't need to do it
http://www.w3schools.com/tags/tag_div.asp for div styling .
And finally abit of personal experience, spend an hour or 2 looking through W3Schools CSS section and learning the basics of styling it's a great way to learn the basic tools you need to work with CSS and make your pages look good !
Edit styling text
<h1>first last</h1>
<p>Coffee snob.</p>
so first you could style them in your css as the elements they are
h1
{
text-align:left;
padding-left: 10px;
text-decoration: underline;
}
p
{
text-align: right;
}
Doing thing your HTML would look exactly as it is you wouldn't have to change anything. Obviously this is something you can only do once for all <p> and <h1> content and every time you use those tags without specifying a class for them it'll look exactly like whatever the above CSS is.
The other option is to do what I suggested with the image and give them a unique class.
p.body
{
text-align: right;
}
Here you'll need to add class to <p> jsut like you did for image which will look like
<p class="body">Coffee snob.</p>
Hope that helps !
Image that describes my situation:
How does it currently look like:
**I have an issue with aligning the text to the images, under the Express Yourself Page.
I have tried setting the paragraphs to be of the same width as each other, based on the wrapper's total width.
The Pictures were able to float left successfully; with the images side by side. However, the text which is supposed to be centrally aligned with it's respective image aren't shifting.
When I experiment with the text, it's either all the text stays at the left or it's centralised; all in a row, below each other. How am I able to shift the respective paragraphs to be side by side each other, centrally aligned to their images?**
<Style>
#wrapper {
width:970px;
margin-left:auto;
margin-right:auto; /* Most crucial thing to align the whole page plus margin-left */
}
#section1 img, #section2 img, #section3 img, #section4 img {
max-width:100%;
float:left;
display:block;
padding-bottom:30px;
}
#section1, #section2, #section3, #section4 {
font:Arial, Helvetica, sans-serif;
font-size:
text-align:center;
}
p.title {
width:323px;
}
hgroup {
font:Arial, Helvetica, sans-serif;
font-size:1em;
font-weight:bold;
padding-top:24px; /*To give space inbetween image and Text*/
width:323px;
}
</style>
<body>
<div id="wrapper">
<section id="section1">
<img src="img/showcase_project1.jpg">
<img src="img/showcase_project2.jpg">
<img src="img/showcase_project3.jpg">
<hgroup>PAVÉ</hgroup>
<p class="title">Illustration Design<br>Avina Tan</p>
<hgroup>REBRANDING HAW PAR VILLA</hgroup>
<p>Branding Design<br>Tan Chin Hwee</p>
<hgroup>DREAMS</hgroup>
<p class="title">Photography<br>Jessie Lam</p>
</section>
<section id="section2">
<img src="img/showcase_project4.jpg">
<img src="img/showcase_project5.jpg">
<img src="img/showcase_project6.jpg">
<hgroup>PAPER NEVER FORGETS</hgroup>
<p class="title">Graphic Design<br>Janelle Qua</p>
<hgroup>‘O THAT TWISTED STORY</hgroup>
<p class="title">Illustration Design<br>Jennifer Soon</p>
<hgroup>HOMEBREW</hgroup>
<p class="title">Branding Design<br>Fiona Lim</p>
</section>
<section id="section3">
<img src="img/showcase_project7.jpg">
<img src="img/showcase_project8.jpg">
<img src="img/showcase_project9.jpg">
<hgroup>FIVE (MUSIC IN PRINT)</hgroup>
<p class="title">Photography<br>Jonathan Liu</p>
<hgroup>PRECIOUS</hgroup>
<p class="title">Graphic and Editorial Design <br>Tzeng Li Syuan</p>
<hgroup>26 HOURS</hgroup>
<p class="title">Digital Design<br>Evelyn Chew & Rachall Tay</p>
</section>
<section id="section4">
<img src="img/showcase_project10.jpg">
<img src="img/showcase_project11.jpg">
<hgroup>JOY IN A CUP</hgroup>
<p class="title">Digital Design<br>Chua Pei En & Lim Si Hui</p>
<hgroup>AZURE AIRLINE APP</hgroup>
<p class="title">Digital Design<br>Tulasi & Lock Phutthaphon</p>
</section>
</div>
</body>
There are a few issues here, but to solve your problem, I'd recommend grouping each image wih its associated <hgroup> and <p class="title"> by wrapping them in a <div> or something and then floating the wrapper. Something like this: http://jsfiddle.net/Lp32mtkm/ .
The reason your version isn't working is because <p> tags and <hgroup> tags are block elements by default (this can be set explicitly with the css property display), which means they automatically start a new line, even if there is space for them on the previous line. <img> tags are actually inline elements by default, which means they will line up next to each other.
EDIT: missed the part about centering the text. All you have to do is put text-align:center on the wrapping element, like so: http://jsfiddle.net/Lp32mtkm/1/ .
I'm having a bit of trouble getting the various products to line up properly on my site. Some of the items have a name long enough to create a second line of text, and when it does so, the items still align with the top of the text rather than aligning the top of each image. Basically I want it to use up some of the empty space above each div to fit a second line of text, rather than pushing my picture down and just aligning at the top. This is the code I'm using to create the divs in a loop within my PHP:
<div class="new_prod_box">
<a href="details.html">
'.$title.'
</a>
<div class="new_prod_bg">
<a href="details.html">
<img src="images/'.$image.'" alt="'.$title.'" title="" class="thumb" border="0" />
</a>
</div>
<a href="cart.php?action=add&id='.$id.'">
<u>Add to cart</u>
</a>
</div>
Here's a picture explaining what I mean: my website
Here's the rules in my CSS:
.new_prod_box{
float:left;
text-align:center;
padding:10px;
width:132px;
height:180px;
}
.new_prod_box a{
padding:5px 0 5px 0;
color:#b5b5b6;
text-decoration:none;
display:block;
}
.new_prod_bg{
width:132px;
height:119px;
text-align:center;
background:url(images/new_prod_box.gif) no-repeat center;
position:relative;
}
Hmmm, if I understand your issue correctly, giving .new_prod_box > a:first-child (selects only the first, top-level <a> element inside .new_prod_box) a defined height should give you what you want. As long as the height is great enough to fit two lines of text in it, it'll keep the elements below in the same position, but still leaves space for the title to break to two lines.
If that isn't what you're looking for, let me know and I'll be happy to help further!
(Edit:) To align single-line titles to the top of the image (rather than having whitespace between them), you could try this method, which I think will work.
First, modify your HTML structure a bit, to add a <span> inside of the first <a> element:
<div class="new_prod_box">
<a href="details.html">
<span>
'.$title.'
</span>
</a>
<div class="new_prod_bg">
<a href="details.html">
<img src="images/'.$image.'" alt="'.$title.'" title="" class="thumb" border="0" />
</a>
</div>
<a href="cart.php?action=add&id='.$id.'">
<u>Add to cart</u>
</a>
</div>
Then, add/modify these styles in your CSS:
.new_prod_box > a:first-child{
height: [tall enough for two lines];
position:relative;
}
.new_prod_box > a:first-child span{
display:block;
position:absolute;
bottom:0;
left:0;
width:100%;
text-align:center;
}
Which I believe should give you what you want. Try it out though, and let me know what happens.
I have this html:
<div class="speaker-list">
<div class="view-content">
<div class="views-row views-row-1 views-row-odd views-row-first">
<div class="views-field views-field-title">
<span class="field-content">
Keith Anderson
</span>
</div>
<div class="views-field views-field-field-job-title">
<div class="field-content">VP, Digital Advisory</div>
</div>
<div class="views-field views-field-field-company">
<div class="field-content">RetailNet Group</div>
</div>
<div class="views-field views-field-title-1">
<span class="field-content">
Store of the Future
</span>
</div>
<div class="views-field views-field-field-headshot">
<div class="field-content">
<div id="file-53" class="file file-image file-image-jpeg contextual-links-region">
<div class="content">
<img typeof="foaf:Image" src="/kanderson.jpg" width="180" height="180" alt="" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
It's dynamically generated by a Drupal view, so I can't change the output html at all. I need to work with what is here. Here's the desired result:
Without any styling on the headshot, this is what it looks like:
I tried to style the image to force it to float to the left of the text:
.view-speaker-list div.view-content div.views-row div.views-field
div.field-content div.file-image div.content img {
border: 1px solid #666;
float: left;
position: relative; /* tried with and without position (inc. absolute) */
left: 30px;
}
Obviously I'm doing something wrong, because this is what I get (with relative position):
and with absolute position:
I've also tried putting the float on the "uppermost" div class that holds the image, with no position on the div:
.view-speaker-list div.view-content div.views-row
div.views-field-field-headshot {
float: left;
}
It gives the same result as the position: relative screenshot.
Where am I going wrong? If I had control over the html I'd do it differently, but I'm not sure how to deal with all of these nested divs.
EDITED TO ADD NEW SCREENSHOT FOR #WEX
Here's what it looks like when I tried to use your code with the html reordered - http://jsfiddle.net/mPa7z/
I'll try to explain the "right" way to use float so that you can see why your way didn't work.
In your post, you try to apply float: left to the <div> surrounding your image, but that technique only works when the element you are floating is above all the elements you want to wrap around it. That "may" solve your problem, but that technique has it's pitfalls if you're trying to use it to create two distinct columns - if the text on the right is taller than the floated element, the text on the right will wrap below it. So then you have to add another container around your non-floated elements to ensure that it won't wrap. This solves your problem, but doesn't really help if you can't even edit your markup!
I'd argue that the technique I've posted below works better, and solves your problem: http://jsfiddle.net/Wexcode/AQQwX/
.view-content {
position: relative;
min-height: 180px;
padding: 0 0 0 180px; }
.views-row { padding: 20px 0 0 20px; }
.views-field-field-headshot {
position: absolute;
top: 0;
left: 0; }
If you have access to the View itself in Drupal, you can reorder the elements. When logged into Drupal, open the View (in Drupal 7: Structure > Views > Viewname), look for "Fields" and click on the triangle next to "add", which will have a popup, then click "rearrange". You can then drag the photo field to be the first item in the View, then adjust your CSS to float the image to the left.
EmmyS,
Instead of trying to get the headshot to float:left, have you considered making the others float:right? This will give the impression that the image is floating left without having to change the markup in any way.
div.speaker-list div.views-row > div.views-field {
float:right;
clear:both;
}
div.speaker-list div.views-row > div.views-field.views-field-field-headshot {
float:none;
clear:none;
}
The above CSS should work with that specific configuration without altering any of your other Drupal generated markup. In order to make sure that other CSS does not interfere, I've applied as much specificity as possible. Since the headshot will be back in the containing <div>, you shouldn't need to alter the size of it unless the store is simply too large (I don't know without looking at your data). Finally the CSS is concise, so you can add any additional styling you need on a per-element basis.
Hope this helps,
FuzzicalLogic
When you can drop somewhere else on the page some code, you can gain control over the HTML by using jQuery. Then you could make modifications to the DOM tree.
But I do not understand why you can not edit the HTML. Isn't Drupal open source? You should be able to find the file using FTP and manipulate it.
i've searched around and seen some examples of how this is done, but i don't really get it and tried all methods but none worked, so i would like to ask if anyone can show me, for my code below, how can i affect the tournytitle when the img is hovered?
<div id="upevents" class="righty">
<div>
<div class="tournytitle">
<div style="font-weight: bold;">Test 2 Hat</div>
<div style="color: #888888; font-size: 10px;">17 . 12 . 2011</div>
</div>
<img src="/images/tourny/jomjom2.jpg" />
</div>
<div>
<div class="tournytitle">
<div style="font-weight: bold;">Test 1 Hat</div>
<div style="color: #888888; font-size: 10px;">12 . 12 . 2011</div>
</div>
<img src="/images/tourny/bane5.jpg" />
</div>
</div>
how should i write my css code for this?
i tried something like
.upevents img:hover + #tournytitle { background-color: yellow; }
but doesn't seem to work.
help much apperciated
As mentioned, your .tournytitle class must be a child of the img your trying to roll over. Your code .upevents img:hover + #tournytitle { background-color: yellow; } is certainly close, you just need to figure out how to comply to the above rule. With this your saying that .tournytitle is an adjacent-child of img, which is not the case in your given code. Also, your class and id symbols are incorrect, watch out for that.
I managed to get your code working by switching .tournytitle and img so that the class is now the adjacent-sibling - http://jsfiddle.net/gmwjw/1/ - I realize this may not be the design your looking for, but its a start.
This may be helpful to you - http://meyerweb.com/eric/articles/webrev/200007a.html
The .tourneytitle must be a child of the img element for you to achieve this. This fiddle shows the way you can reveal your image by hovering over your .tournytitle: http://jsfiddle.net/fWxH3/203/
To get what you want, you would need to change your HTML so that somehow your tournytitle div is a child of your img tag. Maybe you can use span's inside of your image tag instead of using div's for everything.