Имеется проект для себя с целями изучения html, css, js, на подобии конструктора мемов, и столкнулся с проблемой, что не знаю как добавить текст на картинку. Для примера пользовался сайтом memgenerator
HTML5 |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
| <!DOCTYPE html>
<html>
<head>
<title>Крафтим мемесы вместе!!!</title>
<link rel="stylesheet" type="text/css" href="Style.css">
<script type='text/javascript' src="js/jquery.js"></script>
<script type='text/javascript' src="js/setPicture.js"></script>
<script type='text/javascript' src="js/md5.js"></script>
</head>
<body bgcolor="gray">
<div id="container" style="width:750px;margin:0 auto;">
<div id="panel1" style="width: 900px;">
<ul>
<li><a href="Main.html">Главная</a></li>
<li><a href="history.html">История мемов</a></li>
<li><a href="archiv.php">Архив мемов</a></li>
</ul>
</div>
<table border="0" cellpadding="0" cellpassing="0" style="width: 900px">
<tr>
<td>
<h1> <font size="+1" color="navy">
Конструктор мемесов <br>
</font>
</h1>
</td>
<td>
<div align="center"> <font size="+2" color="red">
Iаблоны с мемесами каждый день! <br>
</font>
</div>
<h2 align="center"> <font size="+1" color="navy">
Выбирай шаблон и пили свой мемес!
</font>
</h2>
</td>
</tr>
<tr valign="top">
<td style="width: 500px; text-align: center;">
<image id='myImage' src='images/DavidBlane.jpg'></image>
<br><br>
<p><textarea name='text_head' id='text_head' onKeyUp='setImage()' onClick="clearText('text_head');" placeholder='Заголовок'>Заголовок</textarea>
Размер шрифта
<select id='font_size_head' onChange='setImage()'>
<option value='24'>24</option>
<option value='26'>26</option>
<option value='28'>28</option>
<option value='30'>30</option>
<option value='32'>32</option>
<option value='34' selected>34</option>
<option value='38'>38</option>
<option value='46'>46</option>
</select>
<p><textarea name='text_txt' id='text_txt' onKeyUp='setImage()' onClick="clearText('text_txt');" placeholder='Текст'>Текст</textarea>
Размер шрифта
<select id='font_size_txt' onChange='setImage()'>
<option value='24'>24</option>
<option value='26'>26</option>
<option value='28' selected>28</option>
<option value='30'>30</option>
<option value='32'>32</option>
<option value='34'>34</option>
<option value='38'>38</option>
<option value='46'>46</option>
</select>
<p><input type='button' value=' Очистить ' onClick='updatePic()'>
<input type='button' value=' Получить мем ' onClick="saveImage();">
<div id='savedImage'>
</div>
</td>
<td style="width: 330px">
<div style='overflow: auto; height: 600px; width: 340px; display: '>
<div class="preview">
<image id='myImage279'
src='images/trollface.jpg' alt="фото trollface"
title="Trollface" onclick="setPic(this.src)"
style='width: 150px; height: 150px;'>
</image>
</div>
<div class="preview">
<image id='myImage279'
src='images/kakoy_pacan.jpg' alt="фото kakoy_pacan"
title="Какой пацан" onclick="setPic(this.src)"
style='width: 150px; height: 150px;'>
</image>
</div>
<div class="preview">
<image id='preview'
src='images/Awot.jpg' alt="фото Awot"
title="Awot" onclick="setPic(this.src)"
style='width: 150px; height: 150px;'>
</image>
</div>
<div class="preview">
<image id='preview'
src='images/Cry_Man.jpg' alt="фото Cry_man"
title="Cry man" onclick="setPic(this.src)"
style='width: 150px; height: 150px;'>
</image>
</div>
<div class="preview">
<image id='preview'
src='images/This_is_sparta.jpg' alt="фото This_is_sparta"
title="Sparta" onclick="setPic(this.src)"
style='width: 150px; height: 150px;'>
</image>
</div>
<div class="preview">
<image id='preview'
src='images/Aliens.jpg' alt="фото Aliens"
title="Aliens" onclick="setPic(this.src)"
style='width: 150px; height: 150px;'>
</image>
</div>
<div class="preview">
<image id='preview'
src='images/Boromir.jpg' alt="фото Boromir"
title="Boromir" onclick="setPic(this.src)"
style='width: 150px; height: 150px;'>
</image>
</div>
<div class="preview">
<image id='preview'
src='images/Plak.jpg' alt="фото Plak"
title="Plak" onclick="setPic(this.src)"
style='width: 150px; height: 150px;'>
</image>
</div>
<div class="preview">
<image id='preview'
src='images/TonyStark.jpg' alt="фото Stark"
title="Тони Старк" onclick="setPic(this.src)"
style='width: 150px; height: 150px;'>
</image>
</div>
<div class="preview">
<image id='preview'
src='images/DavidBlane.jpg' alt="фото Blane"
title="Дэвид Блэйн" onclick="setPic(this.src)"
style='width: 150px; height: 150px;'>
</image>
</div>
</div>
</td>
</tr>
</table>
</div>
<hr size="6" width="100%">
<div>
<h4 align="center"><font size="+1" color="navy">
Тестовый и сырой варик. Ведётся допил страницы. <br>
<img id="danger" src="images/danger.png" alt="Privet!" style='width: 100px; height: 100px;'>
</font>
</h4>
</div>
</body>
</html> |
|
CSS |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| #panel1 ul li , li{
float: left;
list-style-type: none;
}
#panel1 ul li a, h2 {
font-size: 25px;
display: block;
padding: 7px 20px;
color: red;
}
#panel1 ul li a:hover {
box-shadow: 1px 1px 3px #333;
text-shadow: 1px 1px 1px #000;
color: aqua;
background-color: darkred;
}
p , ul li {
font-size: 20px;
}
a {
text-decoration: none;
}
#myImage {
width: 450px;
height: 450px;
}
.preview {
float: left;
display: block;
margin: 4px;
}
h1 {
text-align: center;
}
#history {
width: 500px;
}
#infoOnPageHistory{
width: 400px; float: left;
margin: 82px 0px 0px 0px;
} |
|
Javascript |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| /*jslint browser: true*/
/*global jQuery, alert*/
var pic = 'DavidBlane.jpg';
var path_pic = 'mempic/';
var click_head = false;
var click_txt = false;
var text_head, text_txt, font_size_head, font_size_txt;
function setImage()
{
text_head = encodeURIComponent(jQuery('#text_head').attr('value'));
text_txt = encodeURIComponent(jQuery('#text_txt').attr('value'));
font_size_head = parseInt(jQuery('#font_size_head').attr('value'));
font_size_txt = parseInt(jQuery('#font_size_txt').attr('value'));
jQuery('#myImage').attr('src','image.php?pic='+ pic +'&text_head=' + text_head + '&text_txt=' + text_txt + '&font_size_head=' + font_size_head + '&font_size_txt=' + font_size_txt);
}
function setPic(selected_url)
{
var item = document.getElementById('myImage');
item.src = selected_url;
}
function updatePic() {
click_head = false;
click_txt = false;
jQuery('#text_head').attr('value', '');
jQuery('#text_txt').attr('value', '');
}
function clearText(id_txt) {
if (id_txt == 'text_head' && !click_head) {
click_head = true;
jQuery('#' + id_txt).attr('value', '');
} else if (id_txt == 'text_txt' && !click_txt) {
click_txt = true;
jQuery('#' + id_txt).attr('value', '');
}
} |
|
Подскажите возможные решения проблемы. Спасибо