Skip to main content

Forums

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #200672
    sallyd09
    Participant

    For my website, I’m creating an array that randomly displays an image and associated text each time. I’ve gotten the array to work, but the first line of text starts on the bottom right corner or the image. How do I get the image to flush left and the text to start on the top with the image? My current display method is using document.write(random_img[random_number]);
    document.write(r_text[random_number]);

    var r_text = new Array ();
    r_text[0] = “Adrian’s online program is totally unique and his approach is founded on the principle that your career should really just be another way to express yourself. I am deeply grateful to have found a more fitting career in brand management and I hope to start a business down the road.<br>Matt, San Francisco”;
    r_text[1] = “I can tell you that after 3+ months using this career pathfinding program that my career outlook has never been better! I am currently going through a complete career change that I would have never dreamed about before I started this program. <br>Conrad, San Francisco”;

    var random_img = new Array();
    random_img[0] = ‘‘;
    random_img[1] = ‘‘;

    var total_testimonials = 2;
    var random_number = Math.floor((Math.random()*total_testimonials));

    document.write(random_img[random_number]);
    document.write(r_text[random_number]);

    #200673
    Paulie_D
    Moderator

    If this is a layout matter I doubt if the JS is relevant.

    We’d need to see the output HTML & CSS in a codepen demo.

    #200963
    Chromawoods
    Participant

    Even without knowing how your HTML and CSS looks, I would not recommend using document.write:
    http://stackoverflow.com/questions/802854/why-is-document-write-considered-a-bad-practice#answer-802943

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.